Types of Data Structure
Types of Data Structure
Linear data structures are usually easy to implement but since the memory
allocation might become complicated, time and space complexities increase.
Stacks:- In stack data structure, elements are stored in the LIFO principle.
That is, the last element stored in a stack will be removed first.
Linked list:- In linked list data structure, data elements are connected
through a series of nodes. And, each node contains the data items and
address to the next node.
Queue:- The queue data structure works in the FIFO principle where first
element stored in the queue will be removed first.
However, they are designed to overcome the issues and limitations of linear
data structures. For instance, the main disadvantage of linear data structures
is the memory allocation. Since the data is allocated sequentially in linear
data structures, each element in these data structures uses one whole
memory block. However, if the data uses less memory than the assigned
block can hold, the extra memory space in the block is wasted. Therefore,
non-linear data structures are introduced. They decrease the space
complexity and use the memory optimally.
Graphs:- In graph data structure, each node is called vertex and each vertex
is connected to other vertices through edges.