Data Structures & AlgorithmsHardTCS NQT · Infosys pattern
A 2-D array A[10][20] (indices from 0) of 4-byte integers is stored in COLUMN-major order starting at address 1000. What is the address of A[5][7]?
- A. 1328
- B. 1300
- C. 1428
- D. 1296
Correct answer: B. 1300
In column-major order the 7 whole columns before it (10 elements each) come first, then 5 elements: offset = (7 × 10 + 5) × 4 = 300, so 1300. 1428 is the row-major answer, (5 × 20 + 7) × 4 + 1000.
Practise more Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questionsArrays, Strings, Linked Lists, Stacks, Queues and Hashing: notes and key points
More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions
- Only the lower triangle (including the diagonal) of a 10 × 10 matrix is stored, row by row, in a 1-D array starting at address 2000, with…
- What is printed? (Python) python a = [3, 8, 1, 9, 4] a.insert(2, 7) a.pop() a.remove(9) print(a, len(a))
- A circular queue of size N = 5 keeps one slot empty. What is printed (dequeued values, 'F' for each rejected enqueue, final count)? c…
- Keys 50, 700, 76, 85, 92, 73, 101 are inserted into a hash table of size 7 with h(k) = k mod 7 and linear probing. What is the final table…
- Keys 22, 33, 44, 55 go into a table of size 11 with quadratic probing h(k) + i² (mod 11). In which slots do they land, in order? python m…
- What is printed? (stack-based reversal of words) python s = "data structures are fun" st = [] for w in s.split(): st.append(w) out = []…