What Is Sorting | Sorting In DSA | Sorting Algorithms | Types of Sorting Algorithms - Cyber Thieve

 Sorting Algorithms


Sorting is the process of arranging the elements of an array so that they can be placed either in ascending or descending order.

Internal Sorting all the data to sort is stored in memory at all times while sorting is in progress. 

External Sorting data is stored outside memory (like on disk) and only loaded into memory in small chunks. External sorting is usually applied in cases when data can't fit into memory entirely.

unsorted array;

int A[10] = { 5, 4, 10, 2, 30, 45, 34, 14, 18, 9 )

Array sorted in Ascending Order;

A[] = { 2, 4, 5, 9, 10, 14, 18, 30, 34, 45 }


There are many techniques by using which, sorting can be performed. In this section of the tutorial, we will discuss each method in detail.


Sorting Algorithms

SN

Sorting Algorithms

Description

1

Bubble Sort

It is the simplest sort method which performs sorting by repeatedly moving the largest element to the highest index of the array. It comprises of comparing each element to its adjacent element and replace them accordingly.

2

Bucket Sort

Bucket sort is also known as bin sort. It works by distributing the element into the array also called buckets. In this sorting algorithms, Buckets are sorted individually by using different sorting algorithm.

3

Comb Sort

Comb Sort is the advanced form of Bubble Sort. Bubble Sort compares all the adjacent values while comb sort removes all the turtle values or small values near the end of the list.

4

Counting Sort

It is a sorting technique based on the keys i.e. objects are collected according to keys which are small integers. Counting sort calculates the number of occurrence of objects and stores its key values. New array is formed by adding previous key elements and assigning to objects.

5

Heap Sort

In the heap sort, Min heap or max heap is maintained from the array elements deending upon the choice and the elements are sorted by deleting the root element of the heap.

6

Insertion Sort

As the name suggests, insertion sort inserts each element of the array to its proper place. It is a very simple sort method which is used to arrange the deck of cards while playing bridge.

7

Merge Sort

Merge sort follows divide and conquer approach in which, the list is first divided into the sets of equal elements and then each half of the list is sorted by using merge sort. The sorted list is combined again to form an elementary sorted array.

8

Quick Sort

Quick sort is the most optimized sort algorithms which performs sorting in O(n log n) comparisons. Like Merge sort, quick sort also work by using divide and conquer approach.

9

Radix Sort

In Radix sort, the sorting is done as we do sort the names according to their alphabetical order. It is the lenear sorting algorithm used for Inegers.

10

Selection Sort

Selection sort finds the smallest element in the array and place it on the first place on the list, then it finds the second smallest element in the array and place it on the second place. This process continues until all the elements are moved to their correct ordering. It carries running time O(n2) which is worst than insertion sort.

11

Shell Sort

Shell sort is the generalization of insertion sort which overcomes the drawbacks of insertion sort by comparing elements separated by a gap of several positions.


Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.

#buttons=(Ok, Go it!) #days=(20)

Our website uses cookies to enhance your experience. Learn More
Ok, Go it!