Question: need help with this program in java Using pen and paper, write out the contents of the array after each pass of the insertion sort

need help with this program in java

Using pen and paper, write out the contents of the array after each pass of the insertion sort algorithm for the following arrays:

int[] arr1 = {14, 28, 17, 74, 32, 16, 5, 9, 41}

int[] arr2 = {2, 14, 17, 23, 31, 36, 42, 47, 49}

int[] arr3 = {97, 81, 74, 68, 62, 54, 50, 41, 13}

Implement the insertion sort algorithm in Java and write out the state of the array after each pass.

Use your implementation to check your pen and paper work.

example code:

int[] exampleArr = {5, 91, 19, 7, 46, 2, 8, 29, 14};

insertionSort(exampleArr);

Example output

[5, 91, 19, 7, 46, 2, 8, 29, 14]

[5, 19, 91, 7, 46, 2, 8, 29, 14]

[5, 7, 19, 91, 46, 2, 8, 29, 14]

[5, 7, 19, 46, 91, 2, 8, 29, 14]

[2, 5, 7, 19, 46, 91, 8, 29, 14]

[2, 5, 7, 8, 19, 46, 91, 29, 14]

[2, 5, 7, 8, 19, 29, 46, 91, 14]

[2, 5, 7, 8, 14, 19, 29, 46, 91]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!