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

Write a Scala program to implement selection sort #5346

Closed
harshraj8843 opened this issue Jan 16, 2024 · 4 comments · Fixed by #5660
Closed

Write a Scala program to implement selection sort #5346

harshraj8843 opened this issue Jan 16, 2024 · 4 comments · Fixed by #5660
Assignees
Labels
closed closed issues/PRs good first issue Good for newcomers program Scala scala related

Comments

@harshraj8843
Copy link
Contributor

Description

Write a Scala 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/implementSelectionSort.scala
  • Commit the changes
  • Create a pull request
@harshraj8843 harshraj8843 added good first issue Good for newcomers program Scala scala related 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
@Murgowt
Copy link
Contributor

Murgowt commented Jan 18, 2024

!assign

@pramod-karkhani
Copy link
Contributor

!assign

@codinasion-bot
Copy link

Hey @pramod-karkhani, this issue is already assigned to @Murgowt! cc/ @codinasion/codinasion

@codinasion-bot codinasion-bot bot added closed closed issues/PRs and removed triage Waiting for review labels May 3, 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 program Scala scala related
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants