Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void insertionSort(Comparable[ ] list)
- {
- for (intindex = 1; index < list.length; index++)
- {
- Comparable key = list [index];
- intposition = index;
- // Shift larger values to the right
- while (position > 0 && key.compareTo(list[position-1]) < 0)
- {
- list[position] = list[position-1];
- position--;
- }
- list[position] = key;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement