What is the best way to implement a dynamic array if you don't know how many elements will be added? Create a new array
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
What is the best way to implement a dynamic array if you don't know how many elements will be added? Create a new array
What is the best way to implement a dynamic array if you don't know how many elements will be added? Create a new array with double the size any time an add operation would exceed the current array size. Create a new array with 1000 more elements any time an add operator would exceed the current size. Create an initial array with a size that uses all available memory Block (or throw an exception for) an add operation that would exceed the current maximum array size.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!