Choose The Most Appropriate Answer:: CS2311: Data Structures Tutorial #07: Trees & BST & Heaps + Answers
Choose The Most Appropriate Answer:: CS2311: Data Structures Tutorial #07: Trees & BST & Heaps + Answers
Prince Sattam Bin Abdul Aziz University جامعة األمير سطام بن عبدالعزيز
4. The ____________ is the only node in a tree that doesn’t have a parent.
a) Parent.
b) Root.
c) Leaf.
d) Child.
6. A(n) ____________ has one, and only one path from a root node to any other node.
(a) Priority queue.
(b) Tree.
(c) Level.
(d) Depth.
1
7. One way to solve the problem of “unbalanced Binary Search Tree” is to use:
(a) Graph.
(b) 2-3 Trees.
(c) Linked List.
(d) None of the above.
9. When dealing with Data stored in Hard Disk, then the best way for searching in such data is using:
(a) Graph.
(b) Linked List.
(c) Stack.
(d) B-Trees.
13. The worst case time complexity for searching a binary tree is:
(a) O(1).
(b) O(log N).
(c) O(N).
(d) O(N2).
14. The average case time complexity for searching a binary tree is:
(a) O(1).
(b) O(log N).
(c) O(N).
(d) O(N2).
2
3
PART II: Essay Questions:
1. Consider the following Binary tree and then answer the coming questions:
Answer:
a. +
b. 4
c.
e. +,x,2,-,a,1,x,3,b
f. 2x a–1+3 xb
g. 15
h. X
i.
4
2. Consider the following Binary Search Tree (BST):
42
32 62
27 37 52 68
17 29 35 39 48 59
(f) How many steps are required to find the node with data value 48?
4 Steps.
5
(g) In the given tree insert a new node with data value 41 and show the resulting tree.
42
32 62
27 37 52 68
17 29 35 39 48 59
41
(h) In the given tree delete the node with data value 42 and draw the resulting tree.
39
32 62
27 37 52 68
17 29 35 48 59
10 8 20 17 15 4 6 9 3
Answer:
20
17 10
9 15 4 6
8 3