Download presentation

Presentation is loading. Please wait.

Published byNestor Maxcy Modified over 3 years ago

1
The Mystery Vault Game Played by radio stations A listener can win up to $25,000 if he/she guesses the correct amount in the vault One guess per hour until somebody wins Let’s play!

2
Binary Trees What are they? no node has more than two child nodes –A tree such that no node has more than two child nodes Why are they useful? –Can be efficiently manipulated –A suitable data structure in many algorithms

3
What is a Binary Tree? A tree such that:A tree such that: –No node has more than two child nodes (called child subtrees). –A node in a binary tree can have 0,1, or 2 child subtrees –Child subtrees must be differentiated, into: Left-child subtree Left-child subtree Right-child subtree Right-child subtree

4
Binary Tree - Example

5
Binary Search Trees Commonly used data structure in searching algorithmsCommonly used data structure in searching algorithms A binary search tree is a binary tree, where elements are stored such that:A binary search tree is a binary tree, where elements are stored such that: –For any node p, the following is true: p>= i, for all nodes i in the left subtree of pp>= i, for all nodes i in the left subtree of p p<=j, for all nodes j in the right subtree of pp<=j, for all nodes j in the right subtree of p

6
Binary Search Tree - Example

7
Searching in a Binary Search Tree Why is a binary search tree good for searching?Why is a binary search tree good for searching?

8
Binary Search Trees (cont) In a binary search tree, searching for existence of a value can be O(log N), where N is the number of nodesIn a binary search tree, searching for existence of a value can be O(log N), where N is the number of nodes How long does it take (in the worst case) to find a value in a(n): –Array? –Linked List?

9
“Bad” Binary Search Trees Below is a binary search tree that is NOT “ balanced ”, its is bad and if so why?Below is a binary search tree that is NOT “ balanced ”, its is bad and if so why?

10
Height to Nodes Ratio For a given binary tree of height (H), and number of nodes (N), the ratioFor a given binary tree of height (H), and number of nodes (N), the ratio of height to nodes is: –H/N For many operations on binary trees, complexity is O(H)For many operations on binary trees, complexity is O(H) If H/N is small (N much bigger than H)If H/N is small (N much bigger than H) –tree levels are “well utilized” –the tree is hence “short” and “bushy” –operations on the tree are less costly

11
Height to Nodes Ratio (cont) For a given binary tree of height (H), and number of nodes (N), the ratioFor a given binary tree of height (H), and number of nodes (N), the ratio of height to nodes is: –H/N For many operations on binary trees, complexity is O(H)For many operations on binary trees, complexity is O(H) If H/N is large (N not much bigger than H)If H/N is large (N not much bigger than H) –tree levels are “ill utilized” –the tree is hence “long” and “thin” – operations on the tree are more costly

12
The Mystery Vault Game Revisited Played by radio stations A listener can win up to $25,000 if he/she guesses the correct amount in the vault One guess per hour until somebody wins I’ll play!

Similar presentations

OK

AA Trees another alternative to AVL trees. Balanced Binary Search Trees A Binary Search Tree (BST) of N nodes is balanced if height is in O(log N) A balanced.

AA Trees another alternative to AVL trees. Balanced Binary Search Trees A Binary Search Tree (BST) of N nodes is balanced if height is in O(log N) A balanced.

© 2018 SlidePlayer.com Inc.

All rights reserved.

To ensure the functioning of the site, we use **cookies**. We share information about your activities on the site with our partners and Google partners: social networks and companies engaged in advertising and web analytics. For more information, see the Privacy Policy and Google Privacy & Terms.
Your consent to our cookies if you continue to use this website.

Ads by Google

Ppt on edge detection matlab Speech reading ppt on ipad Ppt on coordinate geometry for class 9 download Ppt on economic development Ppt on time management techniques Moral stories for kids ppt on batteries Ppt on e banking in india Ppt on power system stability ball Download ppt on transformation of energy Ppt on computer malwares anti-malware