Data Structure
Linear Data Structures
Data Structure | Characteristics | Advantages | Disadvantages |
---|---|---|---|
Array | Fixed size, elements stored in contiguous memory locations. | Fast access to elements by index. | Fixed size, inefficient resizing. |
Linked List | Dynamic size, elements linked using pointers. | Easy insertion and deletion. | Slower access to elements due to sequential traversal. |
Stack | LIFO (Last In First Out) structure, can be implemented using arrays or linked lists. | Easy to implement; provides last-in, first-out access. | Limited access flexibility (only top of stack accessible). |
Queue | FIFO (First In First Out) structure, can be implemented using arrays or linked lists. | Ordered data management; ensures first-in, first-out access. | Limited access flexibility (only front of queue accessible). |
Non -Linear Data Structures
Data Structure | Characteristics | Advantages | Disadvantages |
---|---|---|---|
Tree | Hierarchical structure with nodes connected by edges, no cycles, one root node. | Reflects structural relationships, efficient search, insert, and delete. | Can become unbalanced, leading to inefficient operations. |
Graph | Consists of vertices/nodes and edges, can be directed or undirected, may contain cycles. | Highly flexible, represents complex relationships and networks. | More complex algorithms required for traversing and searching. |
Heap | Specialized tree-based structure that satisfies the heap property (e.g., min-heap or max-heap). | Efficient for priority queue operations, good for quick access to max/min. | Primarily used for priority queues, not for search operations. |