Sorting and Simple sorting techniques??

In this article, I hope to outline the below topics,

  • What is sorting?
  • Sorting techniques
  • Simple sorting techniques

Under simple sorting, I’ll be discussing Bubble sort, Selection sort, and Insertion sort.

Sorting simply means arranging data of a list in a descending or ascending order. We can sort numbers, names, telephone numbers, addresses, etc considering the numerical and alphabetical order. In sorting, we compare the other data items in the array list and replace the relevant data item in the relevant place.

Two main types of sorting techniques are available in Data Structure.

  • Simple sorting algorithms
  • Advanced sorting algorithms

Under simple sorting, several sorting techniques are using. Those techniques are,

  • Bubble sorting
  • Selection sorting
  • Insertion sorting

Bubble sorting is one of the simplest sorting techniques. In this technique, two adjoining data values in the list are compared to each other and swap if the values are not in order. This method repeats until the list of data is completely sorted either in descending order or ascending order.
The third pass is functioned to make sure that the list is completely ordered.

First pass
Second pass

The third pass is functioned to make sure that the list is completely ordered.

Third pass

The array is separated into two lists as a sorted list and an unsorted list. The first element of the unsorted array is considered as the minimum value and let’s define it as “x”. Initially, the entire list is unsorted and The list with element “x” is the sorted list and the rest of the array is the unsorted list. “x” is compared with the elements in the unsorted list and figure out the minimum value. Then after swap “x” and the current minimum value. This process is repeated until the entire array is sorted.

As in the selection sort, the array is virtually separated into two segments — Sorted array and Unsorted array. The first pair is considered in the first go and if those values are in order, it is taken as the sorted array. If those values are not in the correct order, values are swapped. Then consider the second pair and if it is not in order, it checks with all the values in the sorted array and values swap to the right side in order to create the correct position for the considered value. The same process is continued until the entire array is sorted.

This is the end of the article. I hope this would be helpful to you. In my next article, I’ll discuss advanced sorting techniques.

Thank You!!!

Undergraduate-Faculty of Information Technology | University of Moratuwa | Sri Lanka