Data Structures GATE CS PYQ QUIZ

Last Updated :
Discuss
Comments

Question 1

Consider the following sequence of operations on an empty stack.

Push(54);push(52);pop();push(55);push(62);s=pop(); 

Consider the following sequence of operations on an empty queue.

enqueue(21);enqueue(24);dequeue();enqueue(28);enqueue(32);q=dequeue(); 

The value of s+q is ___________.

  • 86

  • 68

  • 24

  • 94

Question 2

Assume that the operators +, -, × are left associative and ^ is right associative. The order of precedence (from highest to lowest) is ^, x , +, -. The postfix expression corresponding to the infix expression a + b × c - d ^ e ^ f is

  • abc × + def ^ ^ -

  • abc × + de ^ f ^ -

  • ab + c × d - e ^ f ^

  • - + a × bc ^ ^ def

Question 3

The result evaluating the postfix expression 10 5 + 60 6 / * 8 – is

  • 284

  • 213

  • 142

  • 71

Question 4

A binary search tree T contains n distinct elements. What is the time complexity of picking an element in T that is smaller than the maximum element in T?

  • Θ(nlogn)

  • Θ(n)

  • Θ(logn)

  • Θ(1)

Question 5

Define Rn to be the maximum amount earned by cutting a rod of length n meters into one or more pieces of integer length and selling them. For i>0, let p[i] denote the selling price of a rod whose length is i meters. Consider the array of prices:

p[1]=1, p[2]=5, p[3]=8, p[4]=9, p[5]=10, p[6]=17, p[7]=18 

Which of the following statements is/are correct about R7?

  • R7=18

  • R7=19

  • R7 is achieved by three different solutions

  • R7 cannot be achieved by a solution consisting of three pieces

Question 6

For a C program accessing X[i][j][k], the following intermediate code is generated by a compiler. Assume that the size of an integer is 32 bits and the size of a character is 8 bits.

  t0 = i ∗ 1024
t1 = j ∗ 32
t2 = k ∗ 4
t3 = t1 + t0
t4 = t3 + t2
t5 = X[t4]

Which one of the following statements about the source code for the C program is CORRECT?

  • X is declared as “int X[32][32][8]”.

  • X is declared as “int X[4][1024][32]”.

  • X is declared as “char X[4][32][8]”.

  • X is declared as “char X[32][16][2]”.

Question 7

Consider the expression tree shown. Each leaf represents a numerical value, which can either be 0 or 1. Over all possible choices of the values at the leaves, the maximum possible value of the expression represented by the tree is ___.

GATECS2014Q38

  • 4

  • 6

  • 8

  • 10

Question 8

A Young tableau is a 2D array of integers increasing from left to right and from top to bottom. Any unfilled entries are marked with ∞, and hence there cannot be any entry to the right of, or below a ∞. The following Young tableau consists of unique entries.

1     2     5      14
3 4 6 23
10 12 18 25
31 ∞ ∞ ∞

When an element is removed from a Young tableau, other elements should be moved into its place so that the resulting table is still a Young tableau (unfilled entries may be filled in with a ∞). The minimum number of entries (other than 1) to be shifted, to remove 1 from the given Young tableau is ____________

  • 2

  • 5

  • 6

  • 18

Question 9

A data structure is required for storing a set of integers such that each of the following operations can be done in (log n) time, where n is the number of elements in the set.

   o	Delection of the smallest element 
o Insertion of an element if it is not already present in the set

Which of the following data structures can be used for this purpose?

  • A heap can be used but not a balanced binary search tree

  • A balanced binary search tree can be used but not a heap

  • Both balanced binary search tree and heap can be used

  • Neither balanced binary search tree nor heap can be used

Question 10

The number of possible min-heaps containing each value from {1, 2, 3, 4, 5, 6, 7} exactly once is _______. Note -This was Numerical Type question.

  • 80

  • 8

  • 20

  • 210

There are 99 questions to complete.

Take a part in the ongoing discussion