A Sorting Algorithm is the process of placing information in a specific order. It means rearranging the information or data in specific order i.e ascending or descending order.
Categories of Sorting
There are two types of sorting :
- External sorting : External sorting methods are used where the data to be sorted cannot be accepted in the memory at the same time and others must be stored in hard disks, floppy disks, magnetic tapes, and other storage devices.
- Internal sorting : Internal sorting occurs when the input data is such that it can be changed in the main memory at the same time.
Different Types of sorting algorithm
There are many different techniques for sorting. Here are some,
- Bubble sort : Bubble sort, also known as comparison sort, is a simple sorting algorithm that loops through a list of items, comparing adjacent elements and swapping them if they are out of order. This is the most basic algorithm, but it is also the most inefficient.
- Insertion sort : Insertion sort is a sorting mechanism that builds a sorted array one object at a time. The array elements are compared sequentially before being organized in a specific order.
- Merge sort : One of the most effective sorting algorithms is merge sort.The strategy is based on divide-and-conquer. Merge sort repeatedly breaks down a list into several sublists until each sublist contains just one element, then merges those sublists into a sorted list.
- Selection sort : This algorithm’s concept is straightforward. There are two sections to the array: sorted and unsorted.. The subarray on the left is sorted, while the subarray on the right is unsorted. The sorted subarray is initially empty, while the unsorted array contains the entire given array.
- Quick sort : It is one of the most effective sorting algorithms, and it works by splitting an array (partition) into smaller ones and swapping (exchanging) the smaller ones based on a comparison with the ‘pivot’ element selected.
Interested in learning about similar topics? Here are a few hand-picked blogs for you!