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

Big O Sheet

The document contains a table summarizing the time complexities of common data structures for operations like indexing, searching, insertion, and deletion in both their average and worst cases. It also includes tables summarizing the time and space complexities of common searching algorithms like depth-first search and binary search, as well as sorting algorithms like merge sort, quick sort, and heap sort.

Uploaded by

Shekhar Tarare
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)
90 views2 pages

Big O Sheet

The document contains a table summarizing the time complexities of common data structures for operations like indexing, searching, insertion, and deletion in both their average and worst cases. It also includes tables summarizing the time and space complexities of common searching algorithms like depth-first search and binary search, as well as sorting algorithms like merge sort, quick sort, and heap sort.

Uploaded by

Shekhar Tarare
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
You are on page 1/ 2

Big O Sheet

Data Structure
Average Worst
Indexing Search Insertion Deletion Indexing Search Insertion Deletion
Basic Array O(1) O(n) - - O(1) O(n) - -

Dynamic Array O(1) O(n) O(n) O(n) O(1) O(n) O(n) O(n)

Single-Linked List O(n) O(n) O(1) O(1) O(n) O(n) O(1) O(1)

Double-Linked List O(n) O(n) O(1) O(1) O(n) O(n) O(1) O(1)

Stack - O(n) O(1) O(1) - O(n) O(1) O(1)

Queue - O(n) O(1) O(1) - O(n) O(1) O(1)

Hash Table - O(1) O(1) O(1) - O(n) O(n) O(n)

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

B-Tree O(log(n)) O(log(n)) O(log(n)) O(log(n)) O(log(n)) O(log(n)) O(log(n)) O(log(n))

Red-Black Tree O(log(n)) O(log(n)) O(log(n)) O(log(n)) O(log(n)) O(log(n)) O(log(n)) O(log(n))

Splay Tree - O(log(n)) O(log(n)) O(log(n)) - O(log(n)) O(log(n)) O(log(n))

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

Searching Algorithms
Algorithm Time Space
Average Worst Worst
Depth First Search (DFS) - O(|E| + |V|) O(|V|)

Breadth First Search (BFS) - O(|E| + |V|) O(|V|)

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

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


Sorting Algorithms
Algorithm Time Auxiliary Space
Best Average Worst Worst
Bubble Sort O(n) O(n2) O(n2) O(1)

Insertion Sort O(n) O(n2) O(n2) O(1)

Selection Sort O(n2) O(n2) O(n2) O(1)

Merge Sort O(n log(n)) O(n log(n)) O(n log(n)) O(n)

Quick Sort O(n log(n)) O(n log(n)) O(n2) O(log(n))

Heap Sort O(n log(n)) O(n log(n)) O(n log(n)) O(1)

Shell Sort O(n log(n)) O(n1.25) O(n(3/2)) O(1)

Radix Sort O(nk) O(nk) O(nk) O(n+k)

You might also like