Presentation is loading. Please wait.

Presentation is loading. Please wait.

SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group Binary Search Tree A running demonstration of binary search.

Similar presentations


Presentation on theme: "SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group Binary Search Tree A running demonstration of binary search."— Presentation transcript:

1 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group Binary Search Tree A running demonstration of binary search data structure and algorithms

2 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group Insert First value is the 'Root' of the tree. 87

3 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group Insert 87 Since 50 is Less than 87, we move to the left sub-tree **Since no sub-tree, 50 is now added as the left leaf** 50

4 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group Insert Since 27 is Less than 87, we move to the left sub-tree Since 27 is Less than 50, we move to the left sub-tree **Since no sub-tree, 27 is now added as the left leaf** 27

5 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group Insert Since 111 is Greater than 87, we move to the right sub-tree **Since no sub-tree, 111 is now added as the right leaf** 111

6 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group Insert Since 99 is Greater than 87, we move to the right sub-tree Since 99 is Less than 111, we move to the left sub-tree **Since no sub-tree, 99 is now added as the left leaf** 99

7 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group Insert Since 42 is Less than 87, we move to the left sub-tree Since 42 is Less than 50, we move to the left sub-tree Since 42 is Greater than 27, we move to the right sub-tree **Since no sub-tree, 42 is now added as the right leaf** 42

8 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group Insert Since 90 is Greater than 87, we move to the right sub-tree Since 90 is Less than 111, we move to the left sub-tree Since 90 is Less than 99, we move to the left sub-tree **Since no sub-tree, 90 is now added as the left leaf** 90

9 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group Insert Since 105 is Greater than 87, we move to the right sub-tree Since 105 is Less than 111, we move to the left sub-tree Since 105 is Greater than 99, we move to the right sub-tree **Since no sub-tree, 105 is now added as the right leaf** 105

10 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group Insert Since 58 is Less than 87, we move to the left sub-tree Since 58 is Greater than 50, we move to the right sub-tree **Since no sub-tree, 58 is now added as the right leaf** 58

11 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group Insert Since 32 is Less than 87, we move to the left sub-tree Since 32 is Less than 50, we move to the left sub-tree Since 32 is Greater than 27, we move to the right sub-tree Since 32 is Less than 42, we move to the left sub-tree **Since no sub-tree, 32 is now added as the left leaf** 32

12 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group Insert Since 68 is Less than 87, we move to the left sub-tree Since 68 is Greater than 50, we move to the right sub-tree Since 68 is Greater than 58, we move to the right sub-tree **Since no sub-tree, 68 is now added as the right leaf** 68

13 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group Insert Since 43 is Less than 87, we move to the left sub-tree Since 43 is Less than 50, we move to the left sub-tree Since 43 is Greater than 27, we move to the right sub-tree Since 43 is Greater than 42, we move to the right sub-tree **Since no sub-tree, 43 is now added as the right leaf** 43

14 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group Insert Since 60 is Less than 87, we move to the left sub-tree Since 60 is Greater than 50, we move to the right sub-tree Since 60 is Greater than 58, we move to the right sub-tree Since 60 is Less than 68, we move to the left sub-tree **Since no sub-tree, 60 is now added as the left leaf** 60

15 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group Insert Since 70 is Less than 87, we move to the left sub-tree Since 70 is Greater than 50, we move to the right sub-tree Since 70 is Greater than 58, we move to the right sub-tree Since 70 is Greater than 68, we move to the right sub-tree **Since no sub-tree, 70 is now added as the right leaf** 70

16 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group Insert Since 51 is Less than 87, we move to the left sub-tree Since 51 is Greater than 50, we move to the right sub-tree Since 51 is Less than 58, we move to the left sub-tree **Since no sub-tree, 51 is now added as the left leaf** 51

17 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group Insert Since 1 is Less than 87, we move to the left sub-tree Since 1 is Less than 50, we move to the left sub-tree Since 1 is Less than 27, we move to the left sub-tree **Since no sub-tree, 1 is now added as the left leaf** 1

18 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group Insert Since 11 is Less than 87, we move to the left sub-tree Since 11 is Less than 50, we move to the left sub-tree Since 11 is Less than 27, we move to the left sub-tree Since 11 is Greater than 1, we move to the right sub-tree **Since no sub-tree, 11 is now added as the right leaf** 11

19 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group Predecessor The node to delete is 50 Predecessor is found by finding the right most node of the 50 nodes left sub-tree

20 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group Sucsessor Successor is found by finding the left most node of the 50 nodes right sub-tree

21 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group How to delete 50? There is a left child so we find predecessor To learn more about finding predecessor insert starting value to data file

22 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group Delete There is a left child so we find predecessor This is how the new tree would appear

23 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group How to delete 105? This is a Leaf case We just remove this node from the tree

24 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group Delete This is a Leaf case This is how the new tree would appear

25 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group How to delete 87? There is a left child so we find predecessor To learn more about finding predicessor insert starting value to data file

26 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group Delete There is a left child so we find predecessor This is how the new tree would appear

27 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group How to delete 111? There is only one child, so replace the node with its only child

28 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group After 111 is replaced by its only child There is only one child, so replace the node with its only child

29 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group PreOrder Traversal

30 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group PreOrder Traversal 1.Visit the root 2.Visit the left sub-tree 3.Visit the right sub-tree

31 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group PreOrder Traversal 1.Visit the root 2.Visit the left sub-tree 3.Visit the right sub-tree

32 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group PreOrder Traversal 1.Visit the root 2.Visit the left sub-tree 3.Visit the right sub-tree

33 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group PreOrder Traversal 1.Visit the root 2.Visit the left sub-tree 3.Visit the right sub-tree

34 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group PreOrder Traversal 1.Visit the root 2.Visit the left sub-tree 3.Visit the right sub-tree

35 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group PreOrder Traversal 1.Visit the root 2.Visit the left sub-tree 3.Visit the right sub-tree

36 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group PreOrder Traversal 1.Visit the root 2.Visit the left sub-tree 3.Visit the right sub-tree

37 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group PreOrder Traversal 1.Visit the root 2.Visit the left sub-tree 3.Visit the right sub-tree

38 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group PreOrder Traversal 1.Visit the root 2.Visit the left sub-tree 3.Visit the right sub-tree

39 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group PreOrder Traversal 1.Visit the root 2.Visit the left sub-tree 3.Visit the right sub-tree

40 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group PreOrder Traversal 1.Visit the root 2.Visit the left sub-tree 3.Visit the right sub-tree

41 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group PreOrder Traversal 1.Visit the root 2.Visit the left sub-tree 3.Visit the right sub-tree

42 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group PreOrder Traversal 1.Visit the root 2.Visit the left sub-tree 3.Visit the right sub-tree

43 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group PreOrder Traversal 1.Visit the root 2.Visit the left sub-tree 3.Visit the right sub-tree

44 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group InOrder Traversal

45 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group InOrder Traversal 1.Visit the left sub-tree 2.Visit the root 3.Visit the right sub-tree

46 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group InOrder Traversal 1.Visit the left sub-tree 2.Visit the root 3.Visit the right sub-tree

47 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group InOrder Traversal 1.Visit the left sub-tree 2.Visit the root 3.Visit the right sub-tree

48 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group InOrder Traversal 1.Visit the left sub-tree 2.Visit the root 3.Visit the right sub-tree

49 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group InOrder Traversal 1.Visit the left sub-tree 2.Visit the root 3.Visit the right sub-tree

50 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group InOrder Traversal 1.Visit the left sub-tree 2.Visit the root 3.Visit the right sub-tree

51 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group InOrder Traversal 1.Visit the left sub-tree 2.Visit the root 3.Visit the right sub-tree

52 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group InOrder Traversal 1.Visit the left sub-tree 2.Visit the root 3.Visit the right sub-tree

53 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group InOrder Traversal 1.Visit the left sub-tree 2.Visit the root 3.Visit the right sub-tree

54 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group InOrder Traversal 1.Visit the left sub-tree 2.Visit the root 3.Visit the right sub-tree

55 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group InOrder Traversal 1.Visit the left sub-tree 2.Visit the root 3.Visit the right sub-tree

56 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group InOrder Traversal 1.Visit the left sub-tree 2.Visit the root 3.Visit the right sub-tree

57 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group InOrder Traversal 1.Visit the left sub-tree 2.Visit the root 3.Visit the right sub-tree

58 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group InOrder Traversal 1.Visit the left sub-tree 2.Visit the root 3.Visit the right sub-tree

59 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group PostOrder Traversal

60 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group PostOrder Traversal 1.Visit the left sub-tree 2.Visit the right sub-tree 3.Visit the root

61 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group PostOrder Traversal 1.Visit the left sub-tree 2.Visit the right sub-tree 3.Visit the root

62 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group PostOrder Traversal 1.Visit the left sub-tree 2.Visit the right sub-tree 3.Visit the root

63 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group PostOrder Traversal 1.Visit the left sub-tree 2.Visit the right sub-tree 3.Visit the root

64 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group PostOrder Traversal 1.Visit the left sub-tree 2.Visit the right sub-tree 3.Visit the root

65 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group PostOrder Traversal 1.Visit the left sub-tree 2.Visit the right sub-tree 3.Visit the root

66 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group PostOrder Traversal 1.Visit the left sub-tree 2.Visit the right sub-tree 3.Visit the root

67 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group PostOrder Traversal 1.Visit the left sub-tree 2.Visit the right sub-tree 3.Visit the root

68 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group PostOrder Traversal 1.Visit the left sub-tree 2.Visit the right sub-tree 3.Visit the root

69 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group PostOrder Traversal 1.Visit the left sub-tree 2.Visit the right sub-tree 3.Visit the root

70 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group PostOrder Traversal 1.Visit the left sub-tree 2.Visit the right sub-tree 3.Visit the root

71 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group PostOrder Traversal 1.Visit the left sub-tree 2.Visit the right sub-tree 3.Visit the root

72 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group PostOrder Traversal 1.Visit the left sub-tree 2.Visit the right sub-tree 3.Visit the root

73 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group PostOrder Traversal 1.Visit the left sub-tree 2.Visit the right sub-tree 3.Visit the root

74 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group Breadth First Traversal

75 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group Breadth First Traversal 1.Visit the root 2.Visit both Children 3.Visit Their Children Visit

76 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group Breadth First Traversal 1.Visit the root 2.Visit both Children 3.Visit Their Children Visit

77 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group Breadth First Traversal 1.Visit the root 2.Visit both Children 3.Visit Their Children Visit

78 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group Breadth First Traversal 1.Visit the root 2.Visit both Children 3.Visit Their Children Visit

79 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group Breadth First Traversal 1.Visit the root 2.Visit both Children 3.Visit Their Children Visit

80 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group Breadth First Traversal 1.Visit the root 2.Visit both Children 3.Visit Their Children Visit

81 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group Breadth First Traversal 1.Visit the root 2.Visit both Children 3.Visit Their Children Visit

82 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group Breadth First Traversal 1.Visit the root 2.Visit both Children 3.Visit Their Children Visit

83 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group Breadth First Traversal 1.Visit the root 2.Visit both Children 3.Visit Their Children Visit

84 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group Breadth First Traversal 1.Visit the root 2.Visit both Children 3.Visit Their Children Visit

85 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group Breadth First Traversal 1.Visit the root 2.Visit both Children 3.Visit Their Children Visit

86 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group Breadth First Traversal 1.Visit the root 2.Visit both Children 3.Visit Their Children Visit

87 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group Breadth First Traversal 1.Visit the root 2.Visit both Children 3.Visit Their Children Visit

88 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group Breadth First Traversal 1.Visit the root 2.Visit both Children 3.Visit Their Children Visit

89 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group Size

90 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group Size Size is the amount of nodes in a tree Size = 14

91 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group Height

92 SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group Height Hight is the number of Levels between the root and lowest leaf Height = 5


Download ppt "SUNY Oneonta Data Structures and Algorithms Visualization Teaching Materials Generation Group Binary Search Tree A running demonstration of binary search."

Similar presentations


Ads by Google