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

Sorting Algorithms

Sorting algorithms

Uploaded by

thinkpinkapp
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)
4 views

Sorting Algorithms

Sorting algorithms

Uploaded by

thinkpinkapp
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/ 1

Sorting Algorithms:

1. Selection Sort:
 Description: A simple comparison-based sorting algorithm. It divides the
input list into two parts: a sorted sublist and an unsorted sublist.
 Time Complexity: O(n²) for the average and worst case.
 Space Complexity: O(1) (in-place sort).
 Stability: Not stable.
 Use Case: Efficient for small datasets or when memory space is limited.
2. Insertion Sort:
 Description: Builds the final sorted array one item at a time, inserting
each item into its proper place in the sorted sublist.
 Time Complexity: O(n²) average and worst case, O(n) best case.
 Space Complexity: O(1).
 Stability: Stable.
 Use Case: Efficient for small datasets or for arrays that are already
partially sorted.
3. Shell Sort:
 Description: A generalization of insertion sort that allows the exchange
of far-apart elements. It reduces the gap between compared elements as
the algorithm runs.
 Time Complexity: Varies depending on gap sequence, typically between
O(n log n) and O(n²).
 Space Complexity: O(1).
 Stability: Not stable.
 Use Case: Faster than insertion sort for larger arrays.
4. Merge Sort:
 Description: A divide-and-conquer algorithm that divides the list into
sublists, sorts them, and then merges them back together.
 Time Complexity: O(n log n) for all cases.
 Space Complexity: O(n) due to auxiliary space for the merged array.
 Stability: Stable.
 Use Case: Efficient for large datasets and can be used with linked lists.

You might also like