GATE CSE 2004

Question 1
The goal of structured programming is to
A
have well indented programs
B
be able to infer the flow of control from the compiled code
C
be able to infer the flow of control form the program text
D
avoid the use of GOTO statements
C Programming   
Question 2
Consider the following C function
 void swap (int a, int b)
{
   int temp;
   temp = a;
   a = b;
   b = temp;
}
In order to exchange the values of two variables x and y.
A
call swap (x, y)
B
call swap (&x, &y)
C
swap (x,y) cannot be used as it does not return any value
D
swap (x,y) cannot be used as the parameters are passed by value
C Programming   Function
Question 3
A single array A[1...MAXSIZE] is used to implement two stacks. The two stacks grow from opposite ends of the array. Variables top1 and top 2 (top1 \lt top 2) point to the location of the topmost element in each of the stacks. If the space is to be used efficiently, the condition for "stack full" is
A
(top1 = MAXSIZE/2) and (top2 = MAXSIZE/2+1)
B
(top1 + top2 = MAXSIZE
C
(top1 = MAXSIZE/2) or (top2 = MAXSIZE)
D
top1 = top2 -1
Data Structure   Stack
Question 4
The following numbers are inserted into an empty binary search tree in the given order: 10, 1, 3, 5, 15, 12, 16. What is the height of the binary search tree (the height is the maximum distance of a leaf node from the root)?
A
2
B
3
C
4
D
6
Data Structure   Binary Search Tree
Question 5
The best data structure to check whether an arithmetic expression has balanced parentheses is a
A
queue
B
stack
C
tree
D
list
Data Structure   Stack
Question 6
Level order traversal of a rooted tree can be done by starting from the root and performing
A
preorder traversal
B
in-order traversal
C
depth first search
D
breadth first search
Data Structure   Binary Tree
Question 7
Given the following input (4322, 1334, 1471, 9679, 1989, 6171, 6173, 4199) and the hash function x mod 10, which of the following statements are true?
i) 9679, 1989, 4199 hash to the same value
ii) 1471, 6171 has to the same value
iii) All elements hash to the same value
iv) Each element hashes to a different value
A
i only
B
ii only
C
i and ii only
D
iii or iv
Data Structure   Hashing
Question 8
Which of the following grammar rules violate the requirements of an operator grammar? P, Q, R are nonterminals, and r,s,t are terminals.
(i)P\rightarrow QR
(ii)P\rightarrow QsR
(iii)P\rightarrow \varepsilon
(iv)P\rightarrow QtRr
A
(i) only
B
(i) and (iii) only
C
(ii) and (iii) only
D
(iii) and (iv) only
Theory of Computation   Context Free Grammar
Question 9
Consider a program P that consists of two source modules M1 and M2 contained in two different files. If M1 contains a reference to a function defined in M2 the reference will be resolved at
A
Edit time
B
Compile time
C
Link time
D
Load time
Compiler Design   Runtime Environment
Question 10
Consider the grammar rule E \rightarrow E1 - E2 for arithmetic expressions. The code generated is targeted to a CPU having a single user register. The subtraction operation requires the first operand to be in the register. If E1 and E2 do not have nay-common sub-expression, in order to get the shortest possible code
A
E1 should be evaluated first
B
E2 should be evaluated first
C
Evaluation of E1 and E2 should necessarily be interleaved
D
Order to evaluation of E1 and E2 is of no consequence
Compiler Design   Parsing
There are 10 questions to complete.

Leave a Comment

Like this FREE website? Please share it among all your friends and join the campaign of FREE Education to ALL.