0% found this document useful (0 votes)
397 views

Big-O Algorithm Complexity Cheat Sheet PDF

This document provides a cheat sheet summarizing the time and space complexity of common data structures and algorithms. It lists the average, worst case, and best case time complexity for operations like search, insertion, and deletion on data structures including arrays, linked lists, stacks, queues, hash tables, and trees. It also summarizes the time and space complexity of common sorting algorithms like quicksort, mergesort, heapsort, insertion sort, and selection sort. The document encourages learning more about algorithms from recommended books and offers a poster version of the Big-O cheat sheet.

Uploaded by

bhavana manglik
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
397 views

Big-O Algorithm Complexity Cheat Sheet PDF

This document provides a cheat sheet summarizing the time and space complexity of common data structures and algorithms. It lists the average, worst case, and best case time complexity for operations like search, insertion, and deletion on data structures including arrays, linked lists, stacks, queues, hash tables, and trees. It also summarizes the time and space complexity of common sorting algorithms like quicksort, mergesort, heapsort, insertion sort, and selection sort. The document encourages learning more about algorithms from recommended books and offers a poster version of the Big-O cheat sheet.

Uploaded by

bhavana manglik
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

4/5/2017 Big­O Algorithm Complexity Cheat Sheet

Common Data Structure Operations
Space
Data Structure Time Complexity
Complexity
Average Worst Worst
Access Search Insertion Deletion Access Search Insertion Deletion
Array Θ(1) Θ(n) Θ(n) Θ(n) O(1) O(n) O(n) O(n) O(n)

Stack Θ(n) Θ(n) Θ(1) Θ(1) O(n) O(n) O(1) O(1) O(n)

Queue Θ(n) Θ(n) Θ(1) Θ(1) O(n) O(n) O(1) O(1) O(n)

Singly­Linked List Θ(n) Θ(n) Θ(1) Θ(1) O(n) O(n) O(1) O(1) O(n)

Doubly­Linked List Θ(n) Θ(n) Θ(1) Θ(1) O(n) O(n) O(1) O(1) O(n)

Skip List Θ(log(n)) Θ(log(n)) Θ(log(n)) Θ(log(n)) O(n) O(n) O(n) O(n) O(n log(n))

Hash Table N/A Θ(1) Θ(1) Θ(1) N/A O(n) O(n) O(n) O(n)

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

Cartesian Tree N/A Θ(log(n)) Θ(log(n)) Θ(log(n)) N/A O(n) O(n) O(n) O(n)

B­Tree Θ(log(n)) Θ(log(n)) Θ(log(n)) Θ(log(n)) O(log(n)) O(log(n)) O(log(n)) O(log(n)) O(n)

Red­Black Tree Θ(log(n)) Θ(log(n)) Θ(log(n)) Θ(log(n)) O(log(n)) O(log(n)) O(log(n)) O(log(n)) O(n)

Splay Tree N/A Θ(log(n)) Θ(log(n)) Θ(log(n)) N/A O(log(n)) O(log(n)) O(log(n)) O(n)

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

KD Tree Θ(log(n)) Θ(log(n)) Θ(log(n)) Θ(log(n)) O(n) O(n) O(n) O(n) O(n)

Array Sorting Algorithms
Algorithm Time Complexity Space Complexity
Best Average Worst Worst
Quicksort Ω(n log(n)) Θ(n log(n)) O(n^2) O(log(n))

Mergesort Ω(n log(n)) Θ(n log(n)) O(n log(n)) O(n)

Timsort Ω(n) Θ(n log(n)) O(n log(n)) O(n)

Heapsort Ω(n log(n)) Θ(n log(n)) O(n log(n)) O(1)

Bubble Sort Ω(n) Θ(n^2) O(n^2) O(1)

Insertion Sort Ω(n) Θ(n^2) O(n^2) O(1)

Selection Sort Ω(n^2) Θ(n^2) O(n^2) O(1)

Tree Sort Ω(n log(n)) Θ(n log(n)) O(n^2) O(n)

Shell Sort Ω(n log(n)) Θ(n(log(n))^2) O(n(log(n))^2) O(1)

Bucket Sort Ω(n+k) Θ(n+k) O(n^2) O(n)

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

Counting Sort Ω(n+k) Θ(n+k) O(n+k) O(k)

Cubesort Ω(n) Θ(n log(n)) O(n log(n)) O(n)

Learn More
Cracking the Coding Interview: 150 Programming Questions and Solutions
Introduction to Algorithms, 3rd Edition
Data Structures and Algorithms in Java (2nd Edition)
High Performance JavaScript (Build Faster Web Application Interfaces)

Get the Official Big­O Cheat Sheet Poster

http://bigocheatsheet.com/ 2/8

You might also like