Presentation is loading. Please wait.

Presentation is loading. Please wait.

CHAPTER 10.1 BINARY SEARCH TREES 6 9 2 4 1 8    1 ACKNOWLEDGEMENT: THESE SLIDES ARE ADAPTED FROM SLIDES PROVIDED WITH DATA STRUCTURES AND ALGORITHMS.

Similar presentations


Presentation on theme: "CHAPTER 10.1 BINARY SEARCH TREES 6 9 2 4 1 8    1 ACKNOWLEDGEMENT: THESE SLIDES ARE ADAPTED FROM SLIDES PROVIDED WITH DATA STRUCTURES AND ALGORITHMS."— Presentation transcript:

1 CHAPTER 10.1 BINARY SEARCH TREES 6 9 2 4 1 8    1 ACKNOWLEDGEMENT: THESE SLIDES ARE ADAPTED FROM SLIDES PROVIDED WITH DATA STRUCTURES AND ALGORITHMS IN C++, GOODRICH, TAMASSIA AND MOUNT (WILEY 2004) AND SLIDES FROM JORY DENNY AND MUKULIKA GHOSH

2 BINARY SEARCH TREES An inorder traversal of a binary search trees visits the keys in increasing order 6 92 418 2

3 SEARCH 6 9 2 4 1 8    3

4 EXERCISE  Show the search paths for the following keys: 8,3,2 4 6 92 418

5 INSERTION 6 9 2 4 18    w 6 92 418 5 w 5

6 EXERCISE BINARY SEARCH TREES Insert into an initially empty binary search tree items with the following keys (in this order). Draw the resulting binary search tree 30, 40, 24, 58, 48, 26, 11, 13 6

7 DELETION 6 9 2 5 18 6 9 2 4 18 5 v w   7

8 DELETION: THE NODE STORING K HAS A LEAF CHILD 6 9 2 5 18 6 9 2 4 18 5 v w   8

9 DELETION: THE NODE STORING K HAS TWO INTERNAL CHILDREN 5 1 8 6 9 v 2 3 1 8 6 9 5 v w z 2 9

10 EXERCISE BINARY SEARCH TREES Insert into an initially empty binary search tree items with the following keys (in this order). Draw the resulting binary search tree 30, 40, 24, 58, 48, 26, 11, 13 Now, remove the item with key 30. Draw the resulting tree Now remove the item with key 48. Draw the resulting tree. 10

11 PERFORMANCE 11


Download ppt "CHAPTER 10.1 BINARY SEARCH TREES 6 9 2 4 1 8    1 ACKNOWLEDGEMENT: THESE SLIDES ARE ADAPTED FROM SLIDES PROVIDED WITH DATA STRUCTURES AND ALGORITHMS."

Similar presentations


Ads by Google