CJCoding With Joseph
15free / daySign inCreate account

Keep a List Sorted as You Insert

SortedIntList 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 — print one after the last line.

Hints4 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.