Professional Documents
Culture Documents
Registration No_________________
10
11
12
131
15
16
17
18
19
20
21
22
23
24
25
26
27
38
29
30
int *(a2[8]);
P. Array of pointers
Q. Pointer to an array
A) a1 is P, a2 is Q
B) a1 is P, a2 is P
C) a1 is Q, a2 is P
D) a1 is Q, a2 is Q
Ans: B
2. The minimum number of comparisons required to determine if an integer appears more than n/2 times in a sorted array
of n integers is
(A) (n)
(B) (logn)
(C) (n)
Ans: B
3. Which of the following operations is not O(1) for an array of sorted data. You may assume that array elements are distinct.
(A) Find the ith largest element
(B) Find the ith smallest element
(C) Delete an element
(D) All of the aboveLet A be a square matrix of size n x n.
Ans: C
Data Structures
for j = 1 to n do
Output(A[i][j]);
Ans: A
Q2. Whether a list of n numbers has two occurrences of the same number in list can be computed in worst case in time
A. O(nlogn)
B. O(n^2)
C. O(n^3)
D. O(logn)
Q3. If a problem has worst case time complexity (nlogn) and O(n^2). And an algorithm A can solve this problem. Which of
the following are possible?
I A has best case complexity (n)
II A has worst case complexity (n (n))
III A has average case complexity (n3)
IV A has worst case complexity (n)
A. I only
B. III only
Data Structures
C. I and II only
D. I and IV only
Q5. Which of the following functions has the largest growth rate? *
A. n^(1/2)
B. n^100
C. 2^(n/2)
D. 2^(n!)
Data Structures
Q2: Alice was making an algorithm for displaying the elements in circular headed linked list but got stuck in and
was not able to resolve it. Help her to get out of it by finding out the wrong segment. She wrote
1.
2.
3.
4.
NSTART =
1F
10
1F
2F
Rooms
650
400
401
NEXTLINK
PREVLINK
Data Structures
2B
3A
450
500
Data Structures
(A) 1,2,3,4,5,6,7
(B) 2,1,4,3,6,5,7
(C) 1,3,2,5,4,7,6
(D) 2,3,4,5,6,7,1
Answer: (B)
1. To evaluate an expression without any embedded function calls:
(A) One stack is enough
(B) Two stacks are needed
(C) As many stacks as the height of the expression tree are needed
(D) A Turing machine is needed in the general case
Answer: (A)
2. What is the minimum number of queue needed to implement priority queue?
A.1
B.2
C.3
D.5
Ans.: B
3. Which of the following is a collection of items into which items can be inserted arbitrarity and from which only
the smallest item can be removed?
A. Descending priority queue
B. Ascending priority queue
C. Fifo queue
D. None of these
Ans-B
4. Number of "ADD" and "REMOVE" operations required to access n/2th elements of a queue of "n" elements so
that the original queue remain the same after the access is (take help of another queue.)
A. 4*n
B. 2*n
C. 4*n-1
D. 2*n-1
Ans-A
5. The five items:A,B,C,D, and E are pushed in a stack, one after the other starting from A.The stack is popped four
times and each element is inserted in a queue.Then two elements are deleted from the queue and pushed back on the
stack.Now one item is popped from the stack.
The popped item is
A.E
B.B
C.C
D.D
Ans-D
Data Structures
1. A binary search tree contains the value 1, 2, 3, 4, 5, 6, 7, 8. The tree is traversed in pre-order and the values
are printed out. Which of the following sequences is a valid output?
(a) 5 3 1 2 4 7 8 6(b) 5 3 1 2 6 4 8 7
(c) 5 3 2 4 1 6 7 8 (d) 5 3 1 2 4 7 6 8
Ans (d)
2. A complete n-ary tree is one in which every node has 0 or n sons. If x is the number of internal nodes of a
complete n-ary tree, the number of leaves in it is given by
(a) x(n 1) +1
(b) xn - 1
(c) xn + 1
(d) x(n+1)
Ans (a)
3. The height of a binary tree is the maximum number of edges in any root to leaf path. The maximum number
of nodes in a binary tree of height h is:
(a) 2h -1 (b) 2h-1 1
(c) 2h+1 -1 (d) 2h+1
ANS C
4. The number of leaf nodes in a rooted tree of n nodes, with each node having 0 or 3 children is:
(a) n/2 (b) (n-1)/3 (c) (n-1)/2 (d) (2n+1)/3
ANS (D)
5. A Priority-Queue is implemented as a Max-Heap. Initially, it has 5 elements. The level-order traversal of the
heap is given below:
10, 8, 5, 3, 2
Two new elements '1' and '7' are inserted in the heap in that order. The level-order traversal of the heap after
the insertion of the elements is:
(a) 10, 8, 7, 5, 3, 2, 1
(b) 10, 8, 7, 2, 3, 1, 5
(c) 10, 8, 7, 1, 2, 3, 5
(d) 10, 8, 7, 3, 2, 1, 5
ANS D
6. The height of a tree is defined as the number of edges on the longest path in the tree. The function shown in
the pseudocode below is invoked as height (root) to compute the height of a binary tree rooted at the tree
pointer root.
Data Structures
fdheg
ecgdf
dchfg
fehdg
Data Structures
1) The number of distinct minimum spanning trees for the weighted graph below is ____
A.
B.
C.
D.
1
3
6
12
Answer: 6
2) Consider the directed graph given below. Which one of the following is TRUE?
(A) The graph doesnt have any topological ordering
(B) Both PQRS and SRPQ are topological ordering
(C) Both PSRQ and SPRQ are topological ordering
(D) PSRQ is the only topological ordering
Answer (C)
3)The degree sequence of a simple graph is the sequence of the degrees of the nodes in the graph in decreasing order. Which of the
following sequences cannot be the degree sequence of any graph?
I. 7, 6, 5, 4, 4, 3, 2, 1
II. 6, 6, 6, 6, 3, 3, 2, 2
III. 7, 6, 6, 4, 4, 3, 2, 2
IV. 8, 7, 7, 6, 4, 2, 1, 1
(A) I and II
(B) III and IV
(C) IV only
(D) II and IV
Answer (D)
Data Structures