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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started