You are on page 1of 5

# 1

## COMPUTER SCIENCE & APPLICATIONS (NET)

Unit Test : DATA STRUCTURE
Time: 00:30 Hour M.M. : 40

______________________________________________________________________________
INSTRUCTIONS: Attempt all the 20 questions. Each question carry two marks.

## 1. What is the running time the following program

Algo example  A, n 
{
if (n = = 1)
return A
m = n/2
return example (A, m)* example (A, n–m)
}
(a)  1 (b)   log n  (c)   n  (d) O(n log n)

## 2. Consider the following pseudo code

i= y
While  i  1 do
begin
if (y%i  0) & &  x%i   0  & &  i%2   0 
then
output i
i = i –1
end
What will be the output when x  24 and y = 18
(a) 6, 2 (b) 2, 6 (c) 2, 4 (d) 6, 4
2
3. Consider the algorithm 1 that takes 3N  2N  1 time to solve a problem and algorithm 2 that takes 10N  1
time to solve the same problem under what conditions if any so that the “less” efficient algo executes faster
than the “ more” effficient algorithm.
(a) N  2 (b) N  2 (c) N  3 (d) N  3
4. If we have a list of 25 elements and we wish to find the minimum and maximum number simultaneously then
Total number of comparision using iterative method = A
Minimum number of comaparisions required for above problem = B.
Then value of A and B are
(a) 36, 36 (b) 49, 36 (c) 48, 36 (d) 36, 48

## 5. If T  n   2T  n   log log n then T  n   ?

(a)   log n  (b)   log log n  (c)   n log n  (d)   n log log 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
2

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
Tn  
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
{
if (n < 2) return;
else counter = 0’,
for (int i = 0; i < 32; i++)
for (int j = 0; j < 32; i++)
for (int i = 0; i < n4; i++)
counter ++;
}

## What is the complexity of the program.

(a) O(n3) (b) O(n4) (c) O(n3 log n) (d) O(n4 log n)

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 – def is:
(a) abc   def   (b) abc   de f  (c) ab  c  d  d f (d) None of these

## 11. Consider the following

5T  n  1 if n  1
(A) T  n   
1 If n  1
 
P.  n
1
3

(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

## (E) T  n   T  n  1  log n T.   log n log log n 

(a) A-P, B-Q, C-R, D-S, E-T (b) A-Q, B-P, C-S, D-R, E-T
(c) A-S, B-Q, C-P, D-R, E-T (d) A-S, B-Q, C-P, D-T, E-R

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

## 12. Consider the following pseudo code

x  1;
i  1;
while  x  1000 
begin
x  2x ;
i  i 1 ;
end
What is the value of ‘i’ at the end of the pseudo code
(a) 4 (b) 5 (c) 6 (d) 8

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

## minimum number of swapping of disks required to achieve the goal is:

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)
}

## (a) Print the numbers from 0 to 10

(b) Print 0, 1, 1, 2, 3, 5, 8, 13, .................
(c) Print the first 10 fibunacci numbers
(d) None of these
20. What does the following code fragment do.
stack s //assume queue is not empty and stack is empty.
Queue q
while(!q.isEmpty())
s.push(q.dequeue());
while(!s.isEmtpy())
q.enqueue(s.pop());
(a) swap the item of queue and stack.
(b) reverse the items of queue
(c) reverse the items of stack.
(d) None of these

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

## COMPUTER SCIENCE & APPLICATIONS (NET)

Unit Test : DATA STRUCTURE

## 1. (c) 2. (a) 3. (d) 4. (c) 5. (a) 6. (c) 7. (a)

8. (a) 9. (d) 10. (d) 11. (d) 12. (b) 13. (d) 14. (d)
15. (a) 16. (b) 17. (c) 18. (a) 19. (c) 20. (b)

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