In a linear data structure each element has at most one predecessor and one successor, so items form a single sequence. Arrays, linked lists, stacks, and queues are linear. They differ in where you may insert and remove: anywhere (array, list), only at one end (stack), or at opposite ends (queue).
Remember
/* array : a[0] a[1] a[2] ...
linked list: head -> . -> . -> NULL
stack : push/pop at the top
queue : enqueue at back, dequeue at front */
Reference
Cheat Sheet
Keep these facts handy while you work with Linear Data Structures in C.
Example 1 — One array, stack order and queue order
The same data removed from opposite ends.
C
#include <stdio.h>
int main(void) {
int items[] = {1, 2, 3};
int n = 3;
printf("stack pops:");
for (int i = n - 1; i >= 0; i--) printf(" %d", items[i]);
printf("\nqueue dequeues:");
for (int i = 0; i < n; i++) printf(" %d", items[i]);
printf("\n");
return 0;
}
Output
stack pops: 3 2 1
queue dequeues: 1 2 3
How It Works
A stack removes the most recent item first.
A queue removes the oldest item first.
Same data, different access rule.
Edge Cases & Pitfalls
Check these before relying on Linear Data Structures in real programs.
wrong
Using the wrong ends
Using a stack when order matters (FIFO) reverses results.
assume
Assuming fast indexing
Only arrays give O(1) access by index. Lists need a walk.
Remember
Key Takeaways
One predecessor, one successor.
Access rules define the type.
Arrays and lists are the base.
One line: In a linear data structure each element has at most one predecessor and one successor, so items form a single sequence.
Frequently Asked Questions
Structures whose elements are arranged in a sequence, such as arrays, linked lists, stacks, and queues.
Yes. Elements are in a sequence; access is limited to one end.
Continue with "C Non-linear Data Structures" next. Structures where items link to many others: trees and graphs. The C Data Structures hub lists every topic in order.