GATE 2006
191 questions
MCQ 1911-mark 191
Questions 111–115 of 191
Answer: (C)
Answer: Selection sort
for (i = n, j = 0; i > 0; i/=2, j += i);
Let Val(j) denote the value stored in the variable j after termination of the for
loop. Which one of the following is true?Answer: (C)
Starting at , the values added are (integer division), and the loop stops when becomes . That is about terms:
using the sum of a geometric series. Integer division loses less than per term, so less than in total, which does not change the order. So .
Answer: (C)
T(n)=2T()+ 1, T(1) = 1
Which one of the following is true?
Answer: (B)
Going back to n, we get .
Final answer:
a:1, b:1, c:2, d:3, e:5, f:8, g:13, h:21
A Huffman code is used to represent the characters. What is the sequence of characters corresponding to the following code?
110111100111010
Answer: (A)
Build the Huffman tree by merging the two smallest nodes each time:
, , , , , , .
Reading the paths from the root, the codewords needed are . The rest are .
No codeword is a prefix of another, so the string splits in only one way:
gives , that is .
Answer: (A)
Which one of the following statements is TRUE about the graph?
Answer: (D)
The intervals are , and .
P and Q. The interval of lies inside that of , so was discovered while was still open. So is a descendant of in the DFS tree, and they are in the same component. The middle drawing (2-cycle) shows one such graph: an edge between and .
R. is discovered at 14, after both and finished (at 12 and 10). Suppose had an edge to or . Then while that vertex was open, was still unvisited, so DFS would have visited before that vertex finished. That did not happen, so has no edge to or . This is why the triangle drawing is crossed out: with the edges and , would be visited inside the call of . is a component by itself (the loop on in the left drawing is just one possible picture).
So there are two components, and .
Answer: (D)