Arrays Flashcards
1
Q
Given an array whose:
address is 1000,
element size is 8
first index is 0
What is the address of the element at index 6?
a.) 48
b.) 1048
c.) 40
d.) 1006
e.) 1005
f.) 1040
A
b.) 1048
The array address is 1000 (not 0), so the correct answer is 1000 + 8(6-0) = 1048
2
Q
Assume you have a three-dimensional array laid out in column-major order with the first element at indices (1, 1, 1). What are the indices of the next element in memory?
a.) (1, 2, 1)
b.) (1, 1, 2)
c.) (2, 1, 1)
A
c.) (2, 1, 1)
In column-major ordering, the first index changes most rapidly.