Skip to content

This program is written in C language and implements the Selection Sort algorithm to sort an array of 5 integers in ascending order.

Notifications You must be signed in to change notification settings

pooja210603/Selection_sort

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

Selection_sort

This program is written in C language and implements the Selection Sort algorithm to sort an array of 5 integers in ascending order. The program initializes an unsorted array of integers and calls the Selection Sort function to sort the array in place. The program then outputs the sorted array.

Algorithm

  1. Initialize an unsorted array of n elements.
  2. Repeat the following process for i = 0 to n-1:
    a. Set the minimum element index to i.
    b. Repeat the following process for j = i+1 to n:
    c. If the element at index j is less than the element at the minimum index, then set the minimum index to j.
    d. If the minimum index is not equal to i, then swap the elements at index i and the minimum index.
  3. The array is now sorted in ascending order.

image

Advantages:

  1. Selection Sort is simple to implement and understand, making it a good choice for small arrays.
  2. Selection Sort is efficient for small arrays, particularly when the number of swaps is a concern.

    The program demonstrates how to use the Selection Sort algorithm to sort an array of integers in ascending order.

Output

image

About

This program is written in C language and implements the Selection Sort algorithm to sort an array of 5 integers in ascending order.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages