Sort Integers
ID: 463; naive
Solution 1 (Java)
Notes
Selection sort
Each time, find the minimum number and swap it with the first number of the unsorted list.
Solution 2 (Java)
Notes
Insertion sort
This is similar to playing card and sorting them. If the current number is larger than its previous number, we make space and move it to a proper position to the left.
Solution 3 (Java)
Notes
Bubble sort
We look at the numbers in pairs. If there is an inversion in the pair, we swap the two numbers. We keep swapping until we cannot swap.
Last updated