codinasion-archive / codinasion-monorepo

Community Monorepo
https://codinasion.org
MIT License
52 stars 170 forks source link

Write a Python program to implement selection sort #5342

Closed harshraj8843 closed 8 months ago

harshraj8843 commented 8 months ago

Description

Write a Python program to implement selection sort

Selection sort is a sorting algorithm that selects the smallest element from an unsorted list in each iteration and places that element at the beginning of the unsorted list.

Pseudocode

procedure selection sort 
   list  : array of items
   n     : size of list

   for i = 1 to n - 1
   /* set current element as minimum*/
      min = i    

      /* check the element to be minimum */

      for j = i+1 to n 
         if list[j] < list[min] then
            min = j;
         end if
      end for

      /* swap the minimum element with the current element*/
      if indexMin != i  then
         swap list[min] and list[i]
      end if
   end for

end procedure

Example

Input  : [8, 5, 2, 6, 9, 3, 1, 4, 0, 7]
Output : [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
How to contribute - Comment `!assign` to assign this issue to yourself - Fork this repository - Create a new branch - Save the solution in `program/program/implement-selection-sort/implement_selection_sort.py` - Commit the changes - Create a pull request
codinasion-bot[bot] commented 8 months ago

👋🏻 Hey @harshraj8843

💖 Thanks for opening this issue 💖

A team member should be by to give feedback soon.

Amedi-Imbira commented 8 months ago

!assign

av-techspot commented 8 months ago

!assign

codinasion-bot[bot] commented 8 months ago

Hey @av-techspot, this issue is already assigned to @Amedi-Imbira! cc/ @codinasion/codinasion