Please enable JavaScript.
Coggle requires JavaScript to display documents.
Arrays - Coggle Diagram
Arrays
Three key points that define a array
Contiguous ares of memory
a memory divided into equal size elements
elements are indexed with contiguous integers
Some times we can specify the first index
Add Remove
starting
O(n)
end
O(1)
anywhere else
O(n)
Random access (Constant Time)
How ?
we can calculate the memory address of any elemnt given the index
array_add DOUBT
array_add + size(index-firstind)
In multidimensional arrays
answer comes form how multi dimensional array are implemented array of arrays
if array of array
row = array_add + no.ofcolumns(index of the row-index of the first roww)
now row gives the add of the array which represents a row we can using earlier method go to a col and hence find array[row][col]
another way ROW MAJOR INDEX
column indices change rapidly
last index changes first
COLUMN MAJOR
simple words the first index changes first
cONTINUOUS VS CONTINUEOUS