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

Time and Space Complexities

The document provides a comparison of various sorting and searching algorithms, detailing their time and space complexities. It includes algorithms like Bubble Sort, Merge Sort, Linear Search, and Binary Search, highlighting their best, average, and worst-case scenarios. Additionally, it discusses time complexities for operations on singly and doubly linked lists.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views2 pages

Time and Space Complexities

The document provides a comparison of various sorting and searching algorithms, detailing their time and space complexities. It includes algorithms like Bubble Sort, Merge Sort, Linear Search, and Binary Search, highlighting their best, average, and worst-case scenarios. Additionally, it discusses time complexities for operations on singly and doubly linked lists.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Sorting Algorithms

Sorting Best Time Average Time Worst Time Space


Algorithm Complexity Complexity Complexity Complexity

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

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

Insertion Sort O(n) O(n^2) O(n^2) 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(n^2) O(n log n)

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

Searching Algorithms

Searching Best Time Worst Time Space


Average Time Complexity
Algorithm Complexity Complexity Complexity

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

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

Linked List

Operation Singly (Time Complexity) Doubly (Time Complexity) Space Complexity

Insertion

At Beginning O(1) O(1) O(1)

At End O(n) O(1) (with tail pointer) O(1)

At Position O(n) O(n) O(1)

Deletion

At Beginning O(1) O(1) O(1)

At End O(n) O(1) (with tail pointer) O(1)

At Position O(n) O(n) O(1)

Searching O(n) O(n) O(1)

array -> searching is O(1), insertion is O(n)


Tree -> searching is O(n), insertion is O(1)

You might also like