Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. public static void insertionSort(Comparable[ ] list)
  2. {
  3. for (intindex = 1; index < list.length; index++)
  4. {
  5. Comparable key = list [index];
  6. intposition = index;
  7. // Shift larger values to the right
  8. while (position > 0 && key.compareTo(list[position-1]) < 0)
  9. {
  10. list[position] = list[position-1];
  11. position--;
  12. }
  13. list[position] = key;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement