Append to a Dynamic Array
easyQuestion 553A DynamicArray makes itself bigger when it runs out of room, so adding to it can never fail. size counts the slots in use, which also makes it the index of the first free slot; the array data may be longer than size. The helper grow() is written for you and swaps in an array twice as long.
Requirements:
1. add(int value) stores value in the first free slot and raises size by one.
2. When every slot is already in use, it calls grow() first so that there is room.
3. Do not change grow() or any other method.
Do NOT write a main method.
Expected output
[10, 20, 30] 3 4 false
= newline. The output ends with a newline, so print one after the last line.
Hints4 available
Sign in to use hintsTopics
Data Structures & AlgorithmsDynamic Arrays
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.