Skip to content
This repository has been archived by the owner on Jul 10, 2024. It is now read-only.

Write a Haskell program to implement selection sort #5335

Closed
harshraj8843 opened this issue Jan 16, 2024 · 2 comments · Fixed by #5768
Closed

Write a Haskell program to implement selection sort #5335

harshraj8843 opened this issue Jan 16, 2024 · 2 comments · Fixed by #5768
Assignees
Labels
closed closed issues/PRs good first issue Good for newcomers Haskell haskell related program

Comments

@harshraj8843
Copy link
Contributor

Description

Write a Haskell 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.hs
  • Commit the changes
  • Create a pull request
@harshraj8843 harshraj8843 added good first issue Good for newcomers Haskell haskell related program labels Jan 16, 2024
@codinasion-bot
Copy link

👋🏻 Hey @harshraj8843

💖 Thanks for opening this issue 💖

A team member should be by to give feedback soon.

@codinasion-bot codinasion-bot bot added the triage Waiting for review label Jan 16, 2024
@NeurantumData
Copy link

!assign

@codinasion-bot codinasion-bot bot added closed closed issues/PRs and removed triage Waiting for review labels Jul 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
closed closed issues/PRs good first issue Good for newcomers Haskell haskell related program
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants