Selfstudys Com File (21)
Selfstudys Com File (21)
Directions for questions 1 to 25: Select the correct alterna- 5. Which of the following is TRUE about the AVL tree?
tive from the given choices. (1) AVL tree is a binary tree.
1. Which of the following data structure(s) can be used to (2) The search time of AVL tree will be always less
represent Stack, Queue, Binary Tree, Hash Table, Heap than (or) equal to the search time of binary search
and Graph? tree.
(A) Array (B) Singly linked list (3) AVL tree is binary search tree with maximum bal-
(C) Doubly linked list (D) Both (A) and (C) ancing factor of 2.
(A) Only (1) (B) Only (1) and (2)
2. Which of the following is a min heap?
(C) Only (1) and (3) (D) All the above
12 6. Which of the following is suitable for the data that con-
tains a relationship between pairs of elements, which is
not necessarily hierarchical in nature?
(A) 14 16 (A) Heaps (B) AVL Trees
(C) Graphs (D) B-Trees
18 13 17 18 7. What is the Number of Null links in a Binary Tree of
‘n’ nodes?
6 (A) n (B) n + 1
(C) n – 1 (D) n/2
8. What is the number of stacks that should be used to
(B) 7 8
implement a queue?
(A) 1 (B) 2
9
(C) 3 (D) 4
10
9. Consider the recursive function for fibonacci sequence:
32 fib (n)
{
if (n ==0)
(C) 64 128 return 0;
else if (n==1)
256 return 1;
512 2048 else
return fib (n – 1) + fib (n – 2);
2 }
What is the Number of additions required, when fib(n)
is invoked ?
4 8
(A) fib(n + 1) – 1 (B) fib (n + 1) + 1
(D) (C) fib (n + 1) – n (D) fib (n + 1) + n
16 128
32 64 10. Which of the following tree traversals are necessary to
get the unique pattern of a tree structure?
256 (A) Only In-order
3. Which traversal of a binary search tree will give the (B) In-order and pre-order
result in an ascending order of elements. (C) Post-order and pre-order
(A) Preorder (D) All the above
(B) In-order Common data for questions 11 and 12:
(C) Post-order Consider the following routines:
(D) None of the above (a special code is required to struct Binary
print elements in ascending order) {
4. Which of the following cannot be implemented using struct Binary * Left ;
self-referential structure? int data;
(A) Graphs (B) AVL trees struct Binary * Right;
(C) Splay trees (D) B-Trees }
3.74 | Programming and Data Structures Test 4
(C) is a circular linked list 23. What will be the post order predecessor of the root
(D) None of these node, in the above resultant tree?
17. Consider the graph below; (A) 26 (B) 21
(C) 28 (D) 9
A B
Linked Answer for Questions 24 and 25:
Consider the circular doubly linked list given below.
D C G
head
a b c
E F
(D) O
n 24. When A( ) routine is applied on the given list, the head
(C) O(n)
2 Right pointer maps to:
(A) Node containing data field as ‘a’
21. Consider post-order and in-order traversal of a tree:
(B) Node containing data field as ‘b’
POSTORDER :- DCBGFEA
(C) Node containing data field as ‘c’
INORDER :- BDCAFGE
(D) The head pointer points to itself
When tree is constructed from above tree traversals
then what are the leaf nodes? 25. To which node N (pointer) points when the following
(A) D, G (B) C, F operation is performed on the new list formed in the
(C) D, E (D) C, G previous question.
(struct node ∗ N)
Linked Answer for Questions 22 and 23:
N = Head → Rptr → Rptr → Lptr → Lptr → Rptr;
Construct an AVL tree with the elements
(A) Head node
21, 26, 30, 9, 4, 14, 28, 18
(B) Node containing data field as ‘a’
22. What will be the root node for the AVL tree? (C) Node containing data field as ‘b’
(A) 26 (B) 21 (D) Node containing data field as ‘c’
(C) 28 (D) 18
Answer Keys
1. A 2. C 3. B 4. A 5. B 6. C 7. B 8. B 9. A 10. B
11. D 12. A 13. B 14. B 15. D 16. A 17. B 18. D 19. B 20. C
21. A 22. B 23. C 24. C 25. D
3.76 | Programming and Data Structures Test 4
D
= 6 (for 5 nodes)
E F
\ For n nodes it will be (n + 1) Null links.
Choice (B) At (F) it can’t reach to vertex (C) as it is not adjacent to
8. 2 stacks required; use one for the Enqueue and the (F). Choice (B)
other for Dequeue. Choice (B) 18. Let us consider a max heap
9. Number of additions in a fibonacci sequence will be fib
(n + 1) – 1. Choice (A) 18
20. Let us consider 5 nodes 22. From the above elements AVL tree will be:
A 21
B
9 28
C
D 4 26 30
14
E
18
To search an element (E) it has to compare 5 elements
\ it is O(n). Choice (C) Choice (B)
21. POST: DCBGFEA 23. Post order for the above tree is 4 18 14 9 26 30 28 21.
IN: BDCAFGE Choice (C)
Consider in order 24. The A( ) routine will reverse the given list
\ Head pointer maps to node containing data field as
BDCAFGE
‘c’.
Choice (C)
A 25.
BDC FGE
c b a
A head
B E
C F
D G