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
Stack
Queue
Linked List
Trees
Hashing
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.
Basic Operations
Following are the basic operations supported by an array.
Traverse - print all the array elements one by one.
Insertion - Adds an element at the given index.
Deletion - Deletes an element at the given index.
Search - Searches an element using the given index or by the value.
Update - Updates an element at the given index.
LIFO
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.
QUEUE
A Queue is a linear data structure that stores a collection of elements. The queue
operates on first in first out (FIFO) algorithm.
LINKED LIST
A Linked List is a data structure. It is linear. The Linked List is like an array but, the Linked
List is not stored sequentially in the memory. Every linked list has 2 parts, the data
section and the address section that holds the address of the next element in the list,
which is called a node.
TREES
A tree is a data structure that has one root node and many sub-nodes. It is another
one of the data structures which are designed on top of a linked list.
HASHING
Hash table is another data structure. It is used to implement an associative array, a
structure that can map keys to values. Hash table uses a hash function to compute
an index into an array of buckets. Hash tables are very useful data structures.
Graph:
In this case, data sometimes hold a relationship between the pairs of elements
which is not necessarily following the hierarchical structure. Such data structure is
termed as a Graph.
A[5]
1
2
3
4
5
6