Keep a List Sorted as You Insert
mediumQuestion 455SortedIntList stays in ascending order at all times, so there is no sort to run afterwards. It starts with room for four values, and a private grow() that copies into a doubled array is written for you.
Requirements:
1. Complete insert(int value): call grow() first when the array is full.
2. Walk back from the last value, shifting anything larger than value one slot right.
3. Drop value into the gap and increase size by one.
Do NOT write a main method.
Expected output
List: 5 List: 1 5 List: 1 5 9 List: 1 3 5 9 List: 1 3 5 7 9 List: 1 2 3 5 7 9 6
= newline. The output ends with a newline, so print one after the last line.
Hints4 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.