Data Structures & AlgorithmsHardGATE CS · DSA
A 2-D array A[0..11][0..29] of 2-byte elements is stored in column-major order starting at address 2000. What is the address of A[9][6]?
- A. 2164
- B. 2552
- C. 2162
- D. 2138
Correct answer: C. 2162
There are 12 rows and 30 columns. In column-major order the offset is ((j − (0))·12 + (i − (0))), times 2 bytes, giving 2162. Using the other order gives 2552.
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
- For each day, a monotonic stack finds how many days you must wait for a strictly warmer temperature (0 if never). What is printed? python…
- Longest run of consecutive integers (in any order) using a hash set and starting only from numbers whose predecessor is absent. What is…
- Quickselect returns the k-th smallest element of an unsorted array in expected O(n) time. For [29, 18, 10, 32, 39, 19, 36, 13] and k = 4…
- A peak is an element larger than its neighbours (array ends count as −∞). Binary search runs on [43, 46, 49, 14, 48, 18, 24, 47, 28]…
- A fixed window of length 3 slides over s = "bcaacbccbbbbac" with a character-count array. At how many starting positions is the window an…
- For each element of [16, 4, 2, 19, 10, 6, 29, 9], find the next greater element to its RIGHT (−1 if none), using a monotonic stack. What…