Data Structure


Q21.

In an array of 2N elements that is both 2-ordered and 3-ordered, what is the maximum number of positions that an element can be from its position if the array were 1-ordered?
GateOverflow

Q22.

Let A(1:8, -5:5, -10:5) be a three dimensional array. How many elements are there in the array A?
GateOverflow

Q23.

A one dimensional array A has indices 1....75. Each element is a string and takes up three memory words. The array is stored at location 1120 decimal. The starting address of A[49] is
GateOverflow

Q24.

The minimum number of comparisons required to determine if an integer appears more than n/2 times in a sorted array of n integers is
GateOverflow

Q25.

An array of n numbers is given, where n is an even number. The maximum as well as the minimum of these n numbers needs to be determined. Which of the following is TRUE about the number of comparisons needed?
GateOverflow

Q26.

Given two arrays of numbers a_{1},...,a_{n} and b_{1},...,b_{n} where each number is 0 or 1, the fastest algorithm to find the largest span(i,j) such that a_{i}+a_{i+1}+...+a_{j}=b_{i}+b_{i+1}+.....+b_{j} , or report that there is no such span,
GateOverflow

Q27.

An element in an array X is called a leader if it is grater than all elements to the right of it in X. The best algorithm to find all leaders in an array.
GateOverflow

Q28.

Let a and b be two sorted arrays containing n integers each, in non-decreasing order. Let c be a sorted array containing 2n integers obtained by merging the two arrays a and b. Assuming the arrays are indexed starting from 0, consider the following four statements I. a[i] \geq b [i] \Rightarrow c[2i] \geq a [i] II. a[i] \geq b [i] \Rightarrow c[2i] \geq b [i] III. a[i] \geq b [i] \Rightarrow c[2i] \leq a [i] IV. a[i] \geq b [i] \Rightarrow c[2i] \leq b [i] Which of the following is TRUE?
GateOverflow

Q29.

A program P reads in 500 integers in the range [0,100] representing the scores of 500 students. It then prints the frequency of each score above 50. What would be the best way for P to store the frequencies?
GateOverflow

Q30.

Two matrices M1 and M2 are to be stored in arrays A and B respectively. Each array can be stored either in row-major or column-major order in contiguous memory locations. The time complexity of an algorithm to compute M1 x M2 will be
GateOverflow