Вы находитесь на странице: 1из 2

Question 1: Which of the following binary trees are BSTs?

If a tree is not a BST, say


why.
A 10 cat 15
/ \ / / \ / \
B C 5 bat rat 5 22
/ / \ \
-3 ant 20 30

Question 2: Using which kind of traversal (preorder, postorder, inorder) visits the
nodes of a BST in sorted order?

Question 3: Here is a binary tree:

Give the results of performing traversals of this tree, printing each node as you visit it:

i. in-order traversal:

ii. pre-order traversal:

iii. post-order traversal:


Question 4: The integers 7, 1, 12, 8, 3, 0, –1, 9 are inserted in that order into an
initially empty binary search tree. Draw the tree after the last insertion

Question 5: Draw the BST that results from inserting the values 1 to 7 in each of the
following orders (reading from left to right):

1. 5 3 7 6 2 1 4
2. 1 2 3 4 5 6 7
3. 4 3 5 2 6 1 7

Вам также может понравиться