As when we create a run time primary array than contiguous memory is reserved in heap, so does this happen in 2d array also , like are contiguous spaces reserved for primary arrays as well as secondary array in heap? as the instructor has shown first primary array stores address 2K second primary array stores address 3K so is the address of last block of first secondary array was 3K-1 and is last block of secondary array with base address 3k will be 4K-1 ?
Memory allocation in 2d arrays
Hi divya
Yes, memory allocation in 2d dynamic arrays are contiguos. Memory is assigned by row wise by default. Like members of first secondary array are assigned first, then members of second secondary array and so on.
Yes, Address of last block of first secondary array is 3K-1 and last block of secondary array with base address 3k will be 4K-1.
Hope it helps:)
1 Like
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.