Data Structures in C are used to store data in an organised and efficient manner. The C Programming language has many data structures like an array, stack, queue, linked list, tree, etc. A programmer selects an appropriate data structure and uses it according to their convenience.
Let us look into some of these data structures:
ARRAY:
An Array is a sequential collection of elements, of the same data type. They are stored sequentially in memory. An Array is a data structure that holds a similar type of elements. The array elements are not treated as objects in c like they are in java.
There are two types of arrays:
- Single dimensional array
- Multidimensional array
STACK:
A stack is a linear data structure. It follows the last in first out approach. A new item is added at the top of a stack. Both insert and deletion operation is performed from one end of the stack.
There are two functions associated with stacks. Push function to add elements to the stack and pop function to remove elements from the stack. Similar to Stack, we have another data structure called Queue.
QUEUE:
A Queue is a linear data structure that stores a collection of elements. The queue operates on first in first out (FIFO) algorithm.
There are 2 pointers, the front is at the front of the queue and rear is at the back of the queue. We add elements from the back of the queue and remove them from the front of the queue.
Top comments (0)