CJCoding With Joseph
15free / daySign inCreate account

Drop the Key Into Place (Insertion Sort)

Insertion sort never swaps. It saves one value as key, shifts every larger value one slot to the right, and then drops key into the gap that is left behind. insertionSort() already saves key and does all the shifting.

Requirements:
1. After the while loop stops, store key at index j + 1 so the list ends up in ascending order.

Do NOT write a main method.

Expected Output:

List: 1 3 6 9
List: 1 2 2

= newline. The output ends with a newline — print one after the last line.

Hints2 available
Topics:
Data Structures & AlgorithmsSorting
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (sysout, psvm, fori)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.