Analysis of Algorithms &
Sorting Algorithms
Sumaiya Afrin Israt
Agenda
•Definition of an Algorithm
•Importance of Algorithm Efficiency
•Time Complexity & Space
Complexity
•Big-O Notation Overview
Presentation title 2
Big-O Notation
•Measures the worst-case scenario
•Common complexities:
•O(1) - Constant Time
•O(log n) - Logarithmic Time
•O(n) - Linear Time
•O(n log n) - Linearithmic Time
•O(n^2) - Quadratic Time
•O(2^n) - Exponential Time
• What is Sorting?
• Importance of Sorting in
Introduction Computing
to Sorting • Classification:
Algorithms • Comparison-based
Sorting
• Non-comparison-based
Sorting
Presentation title 4
Bubble Sort
•Concept: Repeatedly swaps
adjacent elements if they are in
the wrong order.
•Time Complexity: O(n^2)
•Space Complexity: O(1)
•Best Case (Already Sorted):
O(n)
•Worst Case (Reverse Sorted):
O(n^2)
Presentation title 5
Selection Sort
•Concept: Repeatedly finds the minimum element and moves it to the
sorted portion.
•Time Complexity: O(n^2)
•Space Complexity: O(1)
•Stable? No
Presentation title 6
Insertion Sort
• Concept: Builds the sorted array one item at a time by
shifting elements.
• Time Complexity: O(n^2)
• Space Complexity: O(1)
• Best Case: O(n)
• Stable? Yes
Presentation title 7
If you have
Navigating
any Q&A sessions
question
please
asked me!!
Presentation title 8
Merge Sort
•Concept: Divide-and-conquer approach, splits array and merges sorted
parts.
•Time Complexity: O(n log n)
•Space Complexity: O(n)
•Stable? Yes
Presentation title 9
Quick Sort
•Concept: Selects a pivot and partitions elements around it.
•Time Complexity: O(n log n) (average)
•Worst Case: O(n^2)
•Space Complexity: O(log n)
•Stable? No
Presentation title 10
Heap Sort
•Concept: Converts array into a heap, extracts elements in sorted order.
•Time Complexity: O(n log n)
•Space Complexity: O(1)
•Stable? No
Presentation title 11
Counting Sort (Non-comparison Sort)
• Concept: Uses array indexing to count
occurrences.
• Time Complexity: O(n + k)
• Space Complexity: O(k)
• Stable? Yes
Presentation title 12
Radix Sort
•Concept: Sorts digits from least to most
significant place.
•Time Complexity: O(nk)
•Stable? Yes
Presentation title 13
Comparison of Sorting
Algorithms
Space
Algorithm Best Case Average Case Worst Case Stable?
Complexity
Bubble Sort O(n) O(n^2) O(n^2) O(1) Yes
Selection Sort O(n^2) O(n^2) O(n^2) O(1) No
Insertion Sort O(n) O(n^2) O(n^2) O(1) Yes
Merge Sort O(n log n) O(n log n) O(n log n) O(n) Yes
Quick Sort O(n log n) O(n log n) O(n^2) O(log n) No
Heap Sort O(n log n) O(n log n) O(n log n) O(1) No
Counting Sort O(n + k) O(n + k) O(n + k) O(k) Yes
Radix Sort O(nk) O(nk) O(nk) O(n + k) Yes
Presentation title 14
Thank you
Sumaiya Afrin Israt