Array: GATE CS Previous Year Questions

Array · Data Structures

17 questions · asked in 12 of 27 years (2000–2026)

MCQ 15 · NAT 21-mark 13 · 2-mark 4

2000Questions per year2026

Questions 6–10 of 17

Q6GATE 2015 (Session 3)2 marksMCQ−0.67 if wrong
Consider the following two C code segments. Y and X are one and two dimensional arrays of size n and nxn respectively, where 2≤n≤102\leq n\leq 10. Assume that in both code segments, elements of Y are initialized to 0 and each element X[i][j] of array X is initialized to i+j. Further assume that when stored in main memory all elements of X are in same main memory page frame.
Code segment 1:
//initialize elements of Y to 0
//initialize elements X[i][j] of X to i+j
for(i = 0; i < n; i++)
Y[i] += X[0][i]; 
Code Segment 2:
//initialize elements of Y to 0
//initialize elements X[i][j] of X to i+j
for(i = 0; i < n; i++)
Y[i] += X[i][0];
Which of the following statements is/are correct?
S1: Final contents of array Y will be same in both code segments
S2: Elements of array X accessed inside the for loop shown in code segment 1 are contiguous in main memory
S3: Elements of array X accessed inside the for loop shown in code segment 2 are contiguous in main memory

Q7GATE 20082 marksMCQ−0.67 if wrong
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

Q8GATE 20071 markMCQ−0.33 if wrong
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?

Q9GATE 20061 markMCQ−0.33 if wrong
Given two arrays of numbers a1,...,ana_{1},...,a_{n} and b1,...,bnb_{1},...,b_{n} where each number is 0 or 1, the fastest algorithm to find the largest span(i,j) such that ai+ai+1+...+aj=bi+bi+1+.....+bja_{i}+a_{i+1}+...+a_{j}=b_{i}+b_{i+1}+.....+b_{j} , or report that there is no such span,

Q10GATE 20061 markMCQ−0.33 if wrong
An element in an array X is called a leader if it is greater than all elements to the right of it in X. The best algorithm to find all leaders in an array.

Keep practising

Topics in Data Structures

All CS topics ›