Drop the Key Into Place (Insertion Sort)
easyQuestion 431Insertion 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, so print one after the last line.
Hints2 available
Sign in to use hintsTopics
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.