trees - unit 1

advertisement
UNIT III: TREES
1. To represent hierarchical relationship between elements, which data structure is suitable?
A. Dequeue.
B. Priority Queue
C. Tree.
D. Graph.
ANSWER: C
2. A binary tree whose every node has either zero or two children is called _______.
A. complete binary tree.
B. binary search tree.
C. extended binary tree.
D. data structure.
ANSWER: C
3. The depth of a complete binary tree is given by _________.
A. Dn = n log2n.
B. Dn = n log2n+1.
C. Dn = log2n.
D. Dn = log2n+1.
ANSWER: D
4. When converting binary tree into extended binary tree, all the original nodes in binary tree are
_____________.
A. internal nodes on extended tree.
B. external nodes on extended tree.
C. vanished on extended tree.
D. live nodes.
ANSWER: A
5. The post order traversal of a binary tree is DEBFCA. Find out the pre order traversal.
A. ABFCDE.
B. ADBFEC.
C. ABDECF.
D. ABDCEF.
ANSWER: C
6.In a binary tree, certain null entries are replaced by special pointers which point to nodes higher in the
tree for efficiency. These special pointers are called _______.
A. leaf.
B. branch.
C. path.
D. thread.
ANSWER: D
7.The inorder traversal of tree will yield a sorted listing of elements of tree in _________.
A. binary trees.
B. binary search trees.
C. heaps.
D. binary heaps.
ANSWER: B
8. When in-order traversing a tree resulted E A C K F H D B G; the pre-order traversal would return
_______________.
A. FAEKCDBHG.
B. FAEKCDHGB.
C. EAFKHDCBG.
D. FEAKDCHBG.
ANSWER: B
9. If a node having two children is deleted from a binary tree, it is replaced by its
Inorder predecessor
Inorder successor
Preorder predecessor
None of the above
ANSWER:B
10. A full binary tree with 2n+1 nodes contain
A. n leaf nodes
B. n non-leaf nodes
C. n-1 leaf nodes
D. n-1 non-leaf nodes
Ans:B
11. A binary tree in which if all its levels except possibly the last, have the maximum number of
nodes and all the nodes at the last level appear as far left as possible, is known as
A. full binary tree.
B. AVL tree.
C. threaded tree.
D. complete binary tree.
Ans:A
12. A full binary tree with n leaves contains
A. n nodes.
B. log n 2 nodes.
C. 2n –1 nodes.
D. n 2 nodes.
Ans:C
13. One can convert a binary tree into its mirror image by traversing it in
A. inorder
B. preorder
C. postorder
D. any order
ANSWER: C
14. The number of leaf nodes in a complete binary tree of depth d is
A. 2^d
B. 2^d–1 +1
C. 2^d+1 +1
D. 2^d
Ans:A
+1
15. The pre-order and post order traversal of a Binary Tree generates the same output. The tree can
have maximum
A. Three nodes
B. Two nodes
C. One node
D. Any number of nodes
Ans:C
16. A binary tree of depth “d” is an almost complete binary tree if
A. Each leaf in the tree is either at level “d” or at level “d–1”
B. For any node “n” in the tree with a right descendent at level “d” all the left descendents of “n” that are
leaves, are also at level “d”
C. Both A. & B.
D. None of the above
Ans:C
17.How many nodes in a tree have no ancestors.
0
1
2
n
Ans. B.
18.In order to get the contents of a Binary search tree in ascending order, one has to traverse it in
A. pre-order.
B. in-order.
C. post order.
D. not possible.
Ans. B.
20. In order to get the information stored in a Binary Search Tree in the descending order, one
should traverse it in which of the following order?
A. left, root, right
B. root, left, right
C. right, root, left
D. right, left, root
Ans. C.
21.When inorder traversing a tree resulted E A C K F H D B G; the preorder traversal would return
FAEKCDBHG
b. FAEKCDHGB
c. EAFKHDCBG
d. FEAKDCHBG
Answer: b
22. Consider the following tree.
If the post order travesal gives ab –cd * + then the label of the nodes 1, 2, 3, ….. will be
a. +, -, *, a, b, c, d
b. a, -, b, +, c, *, d
c. a, b, c, d, -, *, +
d. -, a, b, +, *, c, d
Ans: a
23. Consider the following tree.
If this tree is used for sorting then a new number 8 is placed as the:
A. left child of node labeled 30
B. right child of node labeled 5
C. right child of node labeled 30
D. left child of node labeled 10
ANSWER: B
24.A binary tree in which every non-leaf node has non-empty left and right subtrees is called a strictly
binary tree. Such a tree with 10 leaves
can not have more than 19 nodes
has exactly 19 nodes
has exactly 17 nodes
can not have more than 17 nodes
Ans: B.
25. Which of the following traversal techniques lists the nodes of a binary search tree in ascending order ?
A. post-order
B. in-order
C. Pre-order
D. None of the above
Ans: B.
26. The number of possible binary trees with 3 nodes is
A. 12
B. 13
C. 5
D. 15
Ans: C
27. A tree can have 2 roots.
A. True
B. False
ANSWER: B
28. Which of the following statements hold true for binary trees?
A. The left subtree of a node contains only nodes with keys less than the node’s key
B. The right subtree of a node contains only one nodes with key greater than the node’s key.
C. Both a and b above
D. Noth left and right subtree nodes contains only nodes with keys less than the node’s key
Answer: C
29. Which of the following ways below is a In order traversal?
A. Root->left sub tree->right sub tree
B. Root-> right sub tree ->left sub tree
C. right sub tree->left sub tree->Root
D. left sub tree->right sub tree->Root
Answer: D
30. The time required in best case for search operation in binary tree is
A. O(n)
B. O(log n)
C. O(2n)
D. O(log 2n)
Answer: B
31. The property of binary tree is
The first subset is called left subtree
The second subtree is called right subtree
The root cannot contain NULL
The right subtree can be empty
ANSWER: D
32. State true or false.
i) An empty tree is also a binary tree.
ii) In strictly binary tree, the outdegree of every node is either o or 2.
True, False
False, True
True, True
False, False
ANSWER: C
33. A Threaded Binary Tree is a binary tree in which every node that does not have a right child has a
THREAD (in actual sense, a Link) ___________Successor.
A. Preorder
B. Inorder
C. Postorder
D. Leveloder
ANSWER: B
34. Which of the following is a property of binary tree?
A. A Binary tree with N internal nodes has 2+N links, N-1 links to internal nodes and N+1 links to
external nodes
B. A Binary tree with N internal nodes has 2*N links, N-1 links to internal nodes and N+1 links to
external nodes.
C. A Binary tree with N internal nodes has 2-N links, N-1 links to internal nodes and N+1 links to
external nodes.
D. A Binary tree with N internal nodes has 2N links, N+1 links to internal nodes and N-1 links to external
nodes.
ANS:D
35.If there are 56 internal nodes in a binary tree then how many external nodes this binary tree will have?
A. 54
B. 55
C. 56
D. 57
ANS:D
36. Which of the following statement is correct?
A.A threaded Binary tree is a binary tree in which every node that does not have a left child has a
THREAD (in actual sense, a link) to its INORDER successor.
B. A threaded Binary tree is a binary tree in which every node that does not have a right child has a
THREAD (in actual sense, a link) to its PREORDER successor.
C. A threaded Binary tree is a binary tree in which every node that does not have a left child has a
THREAD (in actual sense, a link) to its INORDER successor.
D. A threaded Binary tree is a binary tree in which every node that does not have a right child has a
THREAD (in actual sense, a link) to its POSTORDER predecessor.
ANS:B
37.A binary tree with 45 internal nodes has _________ links to external nodes.
A.44
B.45
C.46
D.90
ANS:C
38.In which of the following tree, parent nodes has key greater than or equal to its both children?
A. Max heap
B. Binary search tree
C. Threaded Binary tree
D. Complete Binary tree
ANS: D
39.If there are N external nodes is a binary tree then what will be the no. of the internal nodes in this
binary tree?
A. N-1
B. N
C. N+1
D. N+2
ANSWER: C
40. In threaded binary tree, the NULL pointer are replaced by the.
A. Preorder successor or Predecessor
B. Inorder successor or predecessor
C. Postorder successor or predecessor
D. NULL pointer are not replaced
ANSWER: B
41. In Complete binary tree the bottom level is filled from _______.
A. Left to right
B. Right to left
C. Not filled at all
D. None of the given options
ANSWER: A
42. If the bottom level of a binary tree is NOT completely filled, depicts that the tree is NOT a ________
A. Complete Binary tree
B. Threaded Binary Tree
C. Expression tree
D. Perfectly compete Binary tree
ANSWER: A
43. In threaded binary tree, the NULL pointers are replaced by the.
A. Preorder successor or predecessor
B. Inorder successor or predecessor
C. Postorder successor or predecessor
D. NULL pointer are not replaced
ANSWER: B
44. An expression tree will always be a,
A. Complete binary tree
B. Binary search tree
C. Heap tree
D. AVL Tree
ANSWER: B
45. In a threaded binary tree which nodes have NULL child pointers,
A. All leaf nodes
B. Nodes other then leaf nodes
C. Root Node
D. None of the nodes
ANSWER: A
46. We implement the heap by ____________ .
A. Threaded Tree
B. AVL tree
C. Complete binary tree
D. Expression
ANSWER: C
47. A binary tree with N internal nodes has _____ links, _______ links to internal nodes and ________
links to external nodes.
A. 2N, N-1, N+1
B. N-1, 2N, N+1
C. N+1, 2N, N-1
D. N+1, N-1, 2N
ANSWER: A
48. By using __________we avoid the recursive method of traversing a Tree, which makes use of stacks
and consumes a lot of memory and time.
A. Binary tree only
B. Threaded binary tree
C. Heap data structure
D. Huffman encoding
49. Which of the following statement is correct?
A. A Threaded Binary Tree is a binary tree in which every node that does not have a left child has a
THREAD (in actual sense, a link) to its INORDER
successor.
B. A Threaded Binary Tree is a binary tree in which every node that does not have a right child has a
THREAD (in actual sense, a link) to its PREOREDR successor.
C. A Threaded Binary Tree is a binary tree in which every node that does not have a right child has a
THREAD (in actual sense, a link) to its INORDER successor.
D. A Threaded Binary Tree is a binary tree in which every node that does not have a right child has a
THREAD (in actual sense, a link) to its POSTORDER successor.
ANSWER: C
50. It is necessary for Huffman encoding tree to be,
A. AVL tree
B. Binary tree
C. Complete binary Tree
D. None of these
ANSWER: B
Download