Java Data Structure Cheat Sheet
Average time complexity of data structures:
Average time complexity of data structures:
Data structure | Access (top) | Access (key) | Search | Insertion | Deletion |
Array | O(1) | O(1) | O(N) | O(N) | O(N) |
Stack | O(1) | O(N) | O(N) | O(1) | O(1) |
Queue | O(1) | O(N) | O(N) | O(1) | O(1) |
Linked List | O(1) | O(N) | O(N) | O(1) | O(1) |
Hash Table | n/a | O(1) | O(1) | O(1) | O(1) |
Binary Search Tree | O(1) | O(log N) | O(log N) | O(log N) | O(log N) |
Heap | O(1) | O(N) | O(N) | O(log N) | O(log N) |
Comments
Post a Comment