Logo

Sorting

AlgorithmTime ComplexitySpace Complexity
BestAverageWorstWorst
Selection SortO(n2)O(n2)O(n2)O(1)
Bubble SortO(n)O(n2)O(n2)O(1)
Insertion SortO(n)O(n2)O(n2)O(1)
Heap SortO(n log(n))O(n log(n))O(n log(n))O(1)
Quick SortO(n log(n))O(n log(n))O(n2)O(n)
Merge SortO(n log(n))O(n log(n))O(n log(n))O(n)

Common Data Structures

Best TC

Data structureAccessSearchInsertionDeletion
ArrayO(1)O(1)O(1)O(1)
StackO(1)O(1)O(1)O(1)
QueueO(1)O(1)O(1)O(1)
Singly Linked listO(1)O(1)O(1)O(1)
Doubly Linked ListO(1)O(1)O(1)O(1)
Hash TableO(1)O(1)O(1)O(1)
Binary Search TreeO(log n)O(log n)O(log n)O(log n)
AVL TreeO(log n)O(log n)O(log n)O(log n)
B TreeO(log n)O(log n)O(log n)O(log n)
Red Black TreeO(log n)O(log n)O(log n)O(log n)

Worst TC

Data structureAccessSearchInsertionDeletion
ArrayO(1)O(N)O(N)O(N)
StackO(N)O(N)O(1)O(1)
QueueO(N)O(N)O(1)O(1)
Singly Linked listO(N)O(N)O(N)O(N)
Doubly Linked ListO(N)O(N)O(1)O(1)
Hash TableO(N)O(N)O(N)O(N)
Binary Search TreeO(N)O(N)O(N)O(N)
AVL TreeO(log N)O(log N)O(log N)O(log N)
Binary TreeO(N)O(N)O(N)O(N)
Red Black TreeO(log N)O(log N)O(log N)O(log N)

Avg TC

Data structureAccessSearchInsertionDeletion
ArrayO(1)O(N)O(N)O(N)
StackO(N)O(N)O(1)O(1)
QueueO(N)O(N)O(1)O(1)
Singly Linked listO(N)O(N)O(1)O(1)
Doubly Linked ListO(N)O(N)O(1)O(1)
Hash TableO(1)O(1)O(1)O(1)
Binary Search TreeO(log N)O(log N)O(log N)O(log N)
AVL TreeO(log N)O(log N)O(log N)O(log N)
B TreeO(log N)O(log N)O(log N)O(log N)
Red Black TreeO(log N)O(log N)O(log N)O(log N)

© 2025 All rights reservedBuilt with DataHub Cloud

Built with LogoDataHub Cloud