An array is declared as follows: int table[2] (5); Its values are stored in memo
ID: 3930644 • Letter: A
Question
An array is declared as follows: int table[2] (5); Its values are stored in memory as shown below. Draw a 2-dimensional diagram showing the contents of the array table In your diagram, what value is stored in table [1][3]? If the start address of table is 1000, w hat is the memory address of table [1][3]? Explain your answer. The binary search function is show n on the reference page, with line numbers. Give the line numbers of the statements in the code which are the key comparisons. A one-dimensional array of integers has been sorted in ascending order, its values are Walk through the code of the binary search and fill in the values in the table below. An iteration is one pass through the while loop. The search ltem value is 19.Explanation / Answer
3a: Draw a 2-dimensional diagram showing the contents of the array table.
3b: In your diagram, what value is stored in table[1][3]: table[1][3] means second row, 4th column, therefore, the value is: 68.
3c: If the start address of table is 1000, what is the memory address of table[1][3]?
If an integer is occupying 4 bytes of space, therefore,
1st value i.e., 16 is stored in location 1000.
2nd value i.e., 32 is stored in location 1004.
And [i][j] th value with m rows, and n columns is stored in location:
startAddress + sizeof(int) * ((i *n) + j) = 1000 + 4 * (1 * 5 + 3) = 1000 + 4 * 8 = 1000 + 32 = 1032.
16 32 18 7 40 29 12 4 68 52Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.