logo CodeStepByStep logo

insertionSort1

Language/Type: Java insertion sort sorting
Related Links:
Author: Sara Jackson (on 2017/12/16)

Write the state of the elements of the list below after the first three odd passes of the outermost loop of the insertion sort algorithm.

// index     0  1  2  3   4   5   6  7
// values  {15, 2, 8, 1, 17, 10, 12, 5}
ArrayList<Integer> numbers = new ArrayList<Integer>(Arrays.asList(15, 2, 8, 1, 17, 10, 12, 5));
insertionSort(numbers);
after pass 1
after pass 3
after pass 5

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.