Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

Complexity Analysis:

Sorting and Searching Time Complexity Space Complexity

Linear searching Best Time Complexity: O(1) Best Space Complexity: O(1)
Average Time Complexity: O(n)
Worst Time Complexity: O(n)

Binary searching Best Time Complexity: O(1) Best Space Complexity: O(1)
Average Time Complexity:
O(logn)
Worst Time Complexity: O(logn)

Bubble sorting Best Time Complexity: O(n^2) space complexity is: O(1)
Average Time Complexity:
O(n^2)
Worst Time Complexity: O(n^2)

Insertion sorting Worst case time complexity: Space complexity: Θ(1)


Θ(n^2)
Average case time complexity:
Θ(n^2)
Best case time complexity: Θ(n)
Selection Sorting Best: (n^2) Space Complexity: O(1)
Average: (n^2)
Worst: O(n^2)

Merge sorting time complexity : O(n log n) The space complexity : O(n)

Quick Sorting worst-case time complexity : O(log n)


O(n²)

best-case time complexity: O(n


log n)

best-case time complexity: O(n


log n)

You might also like