I have an array of size 256 (index ranging [0, 255]), where each array element is an 8 byte integer. Now I am randomly generating the indexes of this array and incrementing the values stored at that index. After the end of the trials, the indexes that still have value 0 would be considered as memory wastage. For this I believe the average memory loss will be 128×8 bytes (on an average the array would be half filled). Is my understanding correct?
Now if I divide the array into 4 sub arrays of 64 elements each (call it subarray 1-4). The index ranges for these subarray would be [0,63] subarray1, [64, 127] subaaray2, [128, 191] subarray3 and [192, 255] subarray4. Initially the memory for these subarrays will not be allocated, and a subarray is allocated only when first index laying in that subarray index range is accessed. For e.g. subarray 2 will be allocated if an index lies in [64,127]. Will this make any difference in the average memory loss?