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

Class Notes - Sorting Algorithms

Uploaded by

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

Class Notes - Sorting Algorithms

Uploaded by

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

Sorting Algorithms:

- Definition: Methods to arrange elements in a list in a specific order.

- Common Algorithms:

1. Bubble Sort:

- Compare adjacent elements and swap if needed.

- Time Complexity: O(n^2).

2. Selection Sort:

- Select the smallest element and place it in the sorted portion.

- Time Complexity: O(n^2).

3. Insertion Sort:

- Insert elements into the correct position of the sorted portion.

- Time Complexity: O(n^2).

4. Merge Sort:

- Divide and conquer algorithm.

- Time Complexity: O(n log n).

5. Quick Sort:

- Uses a pivot to partition the array.

- Time Complexity: O(n log n) (average case).

6. Heap Sort:

- Uses a binary heap structure.

- Time Complexity: O(n log n).

- Use Cases:

- Sorting numbers, strings, and custom objects.

You might also like