menu
techminis

A naukri.com initiative

google-web-stories
Home

>

Programming News

>

Sorting al...
source image

Prodevelopertutorial

3w

read

83

img
dot

Image Credit: Prodevelopertutorial

Sorting algorithm 2: Selection Sort

  • Selection sort is a sorting technique where the smallest element is taken from the array and placed at the first, same steps are continued for rest of the elements.
  • The steps for performing selection sort are as follows: 1. Get the smallest element from the array list. 2. Exchange it with the first position. 3. Obtain the second smallest element and exchange it with the second position. 4. Continue the steps till all the array elements are sorted.
  • The time complexity of selection sort is O(n^2), where n is the number of elements in the array. It has the same time complexity for best case, worst case, and average case.
  • The implementation of selection sort in C involves using two nested loops to iterate through the array and swap elements if necessary. The sorted array is printed as the output.

Read Full Article

like

5 Likes

For uninterrupted reading, download the app