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




There are 5 questions to complete.

Leave a Comment