Every data structure has its own advantages and disadvantages while performing the following operations:
- Insert a new data item
- Delete a specified item
- Search for a specified item
The summary of Advantages and Disadvantages of Data Structure
Data Structure | Advantages | Disadvantages |
---|---|---|
Stack | Provides Last-In-First-Out (LIFO) access | Slow access to other items than on last position |
Queue | Provides First-In-First-Out (FIFO) access | Slow access to other items than on first position |
Array | Fast Insertion, Fast search if index is known | Fixed Size, Slow Insertion, Slow Deletion |
Ordered Array | Quicker search than unsorted array | Fixed Size, Slow Insertion, Slow Deletion |
Linked List | Quick Deletion, Quick Insertion | Slow search |
Hash Table | Fast Insertion, Very fast access for known key | Slow access if key is now known, Slow deletion, Inefficient memory usage |
Binary Tree | Quick search, insertion, deletion (if tree remains balanced) | Deletion algorithm is complex |
Red-black tree | Quick search, insertion, deletion, Tree always balanced | Complex |
2-3-4 Tree | Quick search, insertion, deletion, Tree always balanced, Similar tress good for disk storage | Complex |
Heap | Fast Insertion, Deletion, access to largest item | Slow access to other items |