0% found this document useful (0 votes)
87 views2 pages

Data Structures Complexity Cheat Sheet

This document is a cheat sheet summarizing the time and space complexity of various data structures and their operations. It includes arrays, stacks, queues, linked lists, hash tables, binary search trees, AVL trees, heaps, graphs, tries, priority queues, and disjoint sets. Each data structure is presented with best, average, and worst-case time complexities for operations such as access, search, insert, and delete, along with their space complexities.

Uploaded by

karanips0007
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
87 views2 pages

Data Structures Complexity Cheat Sheet

This document is a cheat sheet summarizing the time and space complexity of various data structures and their operations. It includes arrays, stacks, queues, linked lists, hash tables, binary search trees, AVL trees, heaps, graphs, tries, priority queues, and disjoint sets. Each data structure is presented with best, average, and worst-case time complexities for operations such as access, search, insert, and delete, along with their space complexities.

Uploaded by

karanips0007
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

■ Data Structures – Time & Space Complexity

(Cheat Sheet)
Data Structure Operation Best Case Average Case Worst Case Space Complexity

Array Access O(1) O(1) O(1) O(n)

Search O(1) O(n) O(n)

Insert O(1) O(n) O(n)

Delete O(1) O(n) O(n)

Stack Push O(1) O(1) O(1) O(n)

Pop O(1) O(1) O(1)

Search O(n) O(n) O(n)

Queue Enqueue O(1) O(1) O(1) O(n)

Dequeue O(1) O(1) O(1)

Search O(n) O(n) O(n)

Singly Linked List Access O(1) O(n) O(n) O(n)

Search O(1) O(n) O(n)

Insert O(1) O(1) O(n)

Delete O(1) O(1) O(n)

Doubly Linked List Access O(1) O(n) O(n) O(n)

Search O(1) O(n) O(n)

Insert O(1) O(1) O(1)

Delete O(1) O(1) O(1)

Hash Table Search O(1) O(1) O(n) O(n)

Insert O(1) O(1) O(n)

Delete O(1) O(1) O(n)

Binary Search Tree (BST) Search O(1) O(log n) O(n) O(n)

Insert O(1) O(log n) O(n)

Delete O(1) O(log n) O(n)

AVL Tree Search O(log n) O(log n) O(log n) O(n)

Insert O(log n) O(log n) O(log n)

Delete O(log n) O(log n) O(log n)

Heap (Binary Heap) Get Min/Max O(1) O(1) O(1) O(n)

Insert O(1) O(log n) O(log n)

Delete O(1) O(log n) O(log n)

Search O(n) O(n) O(n)

Graph (Adj. List) Traversal O(V) O(V+E) O(V+E) O(V+E)

Graph (Adj. Matrix) Traversal O(V²) O(V²) O(V²) O(V²)


Data Structure Operation Best Case Average Case Worst Case Space Complexity

Trie Search O(m) O(m) O(m) O(ALPHABET × n)

Insert O(m) O(m) O(m)

Delete O(m) O(m) O(m)

Priority Queue (Heap) Insert O(1) O(log n) O(log n) O(n)

Delete O(1) O(log n) O(log n)

Peek O(1) O(1) O(1)

Disjoint Set (Union-Find) Find O(1) O(α(n)) O(α(n)) O(n)

Union O(1) O(α(n)) O(α(n))

You might also like