Question 1 |

The goal of structured programming is to

have well indented programs | |

be able to infer the flow of control from the compiled code | |

be able to infer the flow of control form the program text | |

avoid the use of GOTO statements |

Question 1 Explanation:

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.call swap (x, y) | |

call swap (&x, &y) | |

swap (x,y) cannot be used as it does not return any value | |

swap (x,y) cannot be used as the parameters are passed by value |

Question 2 Explanation:

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

(top1 = MAXSIZE/2) and (top2 = MAXSIZE/2+1) | |

(top1 + top2 = MAXSIZE | |

(top1 = MAXSIZE/2) or (top2 = MAXSIZE) | |

top1 = top2 -1 |

Question 3 Explanation:

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)?

2 | |

3 | |

4 | |

6 |

Question 4 Explanation:

Question 5 |

The best data structure to check whether an arithmetic expression has balanced parentheses is a

queue | |

stack | |

tree | |

list |

Question 5 Explanation:

Question 6 |

Level order traversal of a rooted tree can be done by starting from the root and performing

preorder traversal | |

in-order traversal | |

depth first search | |

breadth first search |

Question 6 Explanation:

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

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

i only | |

ii only | |

i and ii only | |

iii or iv |

Question 7 Explanation:

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

(i)P\rightarrow QR

(ii)P\rightarrow QsR

(iii)P\rightarrow \varepsilon

(iv)P\rightarrow QtRr

(i) only | |

(i) and (iii) only | |

(ii) and (iii) only | |

(iii) and (iv) only |

Question 8 Explanation:

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

Edit time | |

Compile time | |

Link time | |

Load time |

Question 9 Explanation:

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

E1 should be evaluated first | |

E2 should be evaluated first | |

Evaluation of E1 and E2 should necessarily be interleaved | |

Order to evaluation of E1 and E2 is of no consequence |

Question 10 Explanation:

There are 10 questions to complete.