Docsity

Binary Search Trees Assignment Solutions, Assignments of Algorithms and Programming

Toggle sidebar
bg1
Assignment 5 (Binary Search Trees)
Due: Tuesday, 5 May 2009
Solution Set
50
70
10
40
80
20
60
30
1. Consider the binary search tree shown above.
a. What tree results after you insert the nodes 65, 75, 43, 47, 35, and 25 in
that order. Note: not an AVL tree; a Binary Search Tree.
50
70
10
40
80
20
60
30
65
75
47
43
35
25
b. After inserting the nodes mention in Part a, what tree results when you
delete node 40 using the following strategies?
i. Show the Part a tree after the deletion if the in-order predecessor is
used as the replacement for the deleted node.
50
70
10
35
80
20
60
30
65
75
47
43
25
Printed 2020/11 ๆœˆ/29 at 23:18
pf2

Partial preview of the text

Download Binary Search Trees Assignment Solutions and more Assignments Algorithms and Programming in PDF only on Docsity!

Assignment 5 (Binary Search Trees)

Due: Tuesday, 5 May 2009

Solution Set

50 70

10

40

80

20

60

30

  1. Consider the binary search tree shown above.

a. What tree results after you insert the nodes 65 , 75 , 43 , 47 , 35 , and 25 in

that order. Note: not an AVL tree; a Binary Search Tree.

50 70

10

40

80

20

60

30

65

75

47

43

35

25

b. After inserting the nodes mention in Part a , what tree results when you

delete node 40 using the following strategies?

i. Show the Part a tree after the deletion if the in-order predecessor is

used as the replacement for the deleted node.

50 70

10

35

80

20

60

30

65

75

47

43

25

Printed 2020/11 ๆœˆ/29 at 23:

ii. Show the Part a tree after the deletion if the in-order successor is

used as the replacement for the deleted node.

50 70

10

43

80

20

60

30

65

75

47

25 35

  1. Given the following data: 8, 13, 6, 10, 21, 19, 4

a. What binary search tree is created by inserting the data in the order give?

b. Given the search key 12, trace the algorithm that searches the binary search tree

that you created in Part a. List the nodes in the order in which the search visits

them.

8, traverse right.

13, traverse left.

10, traverse right.

FAIL.

Printed 2020/11 ๆœˆ/29 at 23: