Professional Documents
Culture Documents
______________________________________________________________________________
INSTRUCTIONS: Attempt all the 20 questions. Each question carry two marks.
6. Suppose the fibonacci number F11 = 89 and F12 = 144, then the value of F16 = ?
(a) 377 (b) 610 (c) 987 (d) 233
7. The complexity of below recurrence:
2T n 1 1 if n 0
Tn
1 otherwise
(a) O(1) (b) O(n) (c) O(logn) (d) O(n2)
8. The minimum number of queue of size ‘n’ required to implement a stack of size ‘n’?
(a) one (b) two (c) three (d) four
9. Consider the following program
void Abrakadabra (int n)
{
if (n < 2) return;
else counter = 0’,
for (int i = 0; i < 32; i++)
Abrakadabra (n/4);
for (int j = 0; j < 32; i++)
Abrakadabra (n/4);
for (int i = 0; i < n4; i++)
counter ++;
}
10. Assume that the operators +, –, × are left associative and is right associative. The order of precedence
(from highest to lowest) is , , , – . The postfix expression corresponding to the infix expression
a + b + c – def is:
(a) abc def (b) abc de f (c) ab c d d f (d) None of these
(B) T n T n – 1 n 2 n 1 Q. n
3
n
(C) T n 2T 1 R. n log n
8
(D) T n 2T n log n S. 5
n
H.O.: 28-A/11, Jia Sarai, Near-IIT, New Delhi-16 , Ph : 011-26851008, 26861009 www.careerendeavour.com
B.O.: 16, 3rd Floor, Mall road, G.T.B. Nagar (Metro Gate No. 3), Delhi-110 009, Ph: 011-65462244, 9540292991
3
13. Suppose ‘c’ is an integer greater than 1, and some function ‘f’ is defined such that f 0 f 1 1 . Which of
the following statement must not be true
n
(a) If f n f c then f n O log n (b) If f n c * f n 2 then f n O c n
2
n
(c) If f n c * f then f n O n log c (d) None of these
2
14. For each non-negative integer n, let Rn be the greatest possible number of regions into which the plane can be
partitioned by n straight lines. For example R0 =1 and R1 = 2. Then Rn has order
(a) n (b) n log n (c) 2n (d) n 2
15. If the expression 2 3 *4 5* 6 7 *8 9 is evaluated with * having precedence over +. Then the
value obtained is the same as the value of which of the following prefix expressions.
(a) + + * + 234 * * 5 + 6789 (b) + * + * 234 * * 5 + 6789
(c) * + + 234 * * 5 + + 6789 (d) * + + + 234 * * 5 + 6789
16. Which of the following expression evaluates to the largest number
(a) The prefix expression + * – 2357 (b) The postfix expression 2 3 + 5 * 7–
(c) The infix expression (2+3) * (5–7) (d) The postfix expression 2 3 + 5 7–*
17. Suppose we have 2n disks of only black or white colour. They are arranged as follows.
We want to arrange them in such a way that all the white disk are on the left side and all the black disks are on
the right side as follows
n n
(a) 2n (b) n (c) (d)
2 4
H.O.: 28-A/11, Jia Sarai, Near-IIT, New Delhi-16 , Ph : 011-26851008, 26861009 www.careerendeavour.com
B.O.: 16, 3rd Floor, Mall road, G.T.B. Nagar (Metro Gate No. 3), Delhi-110 009, Ph: 011-65462244, 9540292991
4
18. What is the maximum number of parenthesis that appear on the stack at any time when the algorithm analyzes
(( ( ( ) ( ( ) ) ( ( ) ) ) for balance parenthesization.
(a) 5 (b) 2 (c) 3 (d) 4
19. What does the following code fragment do
Queue q
q.enqueue (0);
q.enqueue(1);
for(i = 0; i<10; i++)
{
a =q.dequeue();
b=q.dequeue();
q.enqueue(b);
q.enqueue(a+b)
printf(“%d”, a)
}
H.O.: 28-A/11, Jia Sarai, Near-IIT, New Delhi-16 , Ph : 011-26851008, 26861009 www.careerendeavour.com
B.O.: 16, 3rd Floor, Mall road, G.T.B. Nagar (Metro Gate No. 3), Delhi-110 009, Ph: 011-65462244, 9540292991
5
H.O.: 28-A/11, Jia Sarai, Near-IIT, New Delhi-16 , Ph : 011-26851008, 26861009 www.careerendeavour.com
B.O.: 16, 3rd Floor, Mall road, G.T.B. Nagar (Metro Gate No. 3), Delhi-110 009, Ph: 011-65462244, 9540292991