Selection Sort using C Program

Selection Sort Algorithm using C

Selection Sort

    • Repeatedly searches for the largest value in a section of the data
      • Moves that value into its correct position in a sorted section of the list
    • Uses the Find Largest algorithm

 Pseudo Code


  • Count comparisons of largest so far against other values
  • Find Largest, given m values, does m-1 comparisons
  • Selection sort calls Find Largest n times,
    • Each time with a smaller list of values
    • Cost = n-1 + (n-2) + … + 2 + 1 = n(n-1)/2


  • Time efficiency
    • Comparisons: n(n-1)/2
    • Exchanges: n (swapping largest into place)
    • Overall: (n2), best and worst cases
  • Space efficiency
    • Space for the input sequence, plus a constant number of local variables


In this lesson we will learn how to write a source code in C programming language for doing simple Selection sort using array in ascending order.

Question : Write a c program for Selection sort.

C Example :

Partner Sites

  • Searching for a program code for selection sort using C ? Then on this Ask Expert page, you will get the program you are looking for.