GATE 2007
184 questions
MCQ 1841-mark 184
Questions 96–100 of 184
Answer: (D)
Exchange argument: take two neighbouring jobs then that start at time . Their cost is . If we swap them, it is . The first is smaller by , so should come first when , that is when . Other jobs are not affected by the swap. So any order with a neighbouring pair out of this rule can be improved, and the best order is non-increasing .
Check with = P1 (1,3), P2 (2,5), P3 (3,2), P4 (4,4), where :
(A) order P3, P1, P4, P2 (increasing ): completion times 2, 5, 9, 14, so .
(B) order P4, P3, P2, P1 (decreasing ): completion times 4, 6, 11, 14, so .
(C) order P4, P2, P3, P1 (decreasing ): completion times 4, 9, 11, 14, so .
(D) order P3, P4, P2, P1 (decreasing ): completion times 2, 6, 11, 14, so , the smallest.
Answer: (D)
What is the average length of the Huffman code for the letters a,b,c,d,e,f?
Answer: (D)
Given probabilities:
Huffman tree:
Codes and lengths:
Average length:
Answer: (D)
Which of the following is the Huffman code for the letter a, b, c, d, e, f?
Answer: (A)
Treat the probabilities as frequencies out of 32: a, b, c, d, e, f get 16, 8, 4, 2, 1, 1.
Build the Huffman tree by merging the two smallest nodes each time: e + f = 1 + 1 = 2, then d + (ef) = 2 + 2 = 4, then c + (def) = 4 + 4 = 8, then b + (cdef) = 8 + 8 = 16, then a + (bcdef) = 16 + 16 = 32.
Label each left branch 0 and each right branch 1. Reading the paths from the root gives a = 0, b = 10, c = 110, d = 1110, e = 11110, f = 11111, which is option (A).
Check with the average code length: (A) gives . The other options are longer on average: (B) has lengths 2, 2, 3, 3, 3, 3, giving ; (C) has lengths 2, 2, 2, 3, 4, 4, giving ; (D) uses 3 bits for every letter, giving 3. So only (A) can be a Huffman code.
Answer: (A)
Suppose that the robot is not allowed to traverse the line segment from (4,4) to (5,4). With this constraint, how many distinct paths are there for the robot to reach (10,10) starting from (0,0)?
Answer: (D)
Now remove the paths that use the segment from (4,4) to (5,4). Such a path has three parts:
- (0,0) to (4,4): 4 moves right and 4 up, so ways.
- The step from (4,4) to (5,4): exactly 1 way.
- (5,4) to (10,10): 5 moves right and 6 up, so ways.
So the number of paths using the segment is .
Allowed paths =
Answer: (D)
How many distinct paths are there for the robot to reach the point (10,10) starting from the initial position (0,0)?
Answer: (A)
A path is fixed by choosing which 10 of the 20 positions are right moves (the other 10 are up moves). The count is .
(B) counts all strings of 20 moves, including those that do not end at . (C) is far too small.
Answer: (A)