Skip to content

Conversation

@dimitrijjedich
Copy link
Collaborator

@dimitrijjedich dimitrijjedich commented Nov 23, 2024

Selectionsort

Implementation happens on the following initial description:

We pick up the first element and assume it is the smallest in the array. After that we iterate trough the array searching for the real smallest element. If we find one, we switch our current with the found one and continue with the next element.

🤔 Thoughts

This is basicly the reverse of the Insertionsort. The easiest way to compare the two is to imagine a hand full of playing cards that should be sorted.

Insertion

We let the first card be and go to the second one. Pick it up and compare it the cards to the left and keep moving left until the card we are holding is bigger then the card to the left and drop it there. To back to our starting point and repeat the process until the last card was picked up and droped.

Selectionsort

We look at our first card and go trough all cards to the right. On the way we mark the lowest card we found. After we went all the way back to the right, we remember the marked card and switch it with the first one and repeat the process with the second card and so on until we reach the last card on the right.

@dimitrijjedich dimitrijjedich self-assigned this Nov 23, 2024
@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants