Tree Applications - PowerPoint PPT Presentation

1 / 6
About This Presentation
Title:

Tree Applications

Description:

binary tree in which each vertex is labeled with a key value ... Recursive procedure for building a BST from list of key values ... – PowerPoint PPT presentation

Number of Views:43
Avg rating:3.0/5.0
Slides: 7
Provided by: catesh
Learn more at: https://www.kirkwood.edu
Category:
Tags: applications | bst | tree

less

Transcript and Presenter's Notes

Title: Tree Applications


1
Section 9.2
  • Tree Applications

2
Binary Search Trees
  • Goal is implementation of an efficient searching
    algorithm
  • Binary Search Tree
  • binary tree in which each vertex is labeled with
    a key value
  • the key value of a vertex is larger than all key
    values in its left subtree, and smaller than all
    key values in its right subtree

3
Recursive procedure for building a BST from list
of key values
  • Start with tree containing one vertex (root) -
    first item in list is assigned as roots key
  • To add a new item
  • compare value to keys already in tree, starting
    at root
  • if value is less than current key, move left if
    greater, move right
  • when value is less than current key and current
    vertex is a leaf, then create new vertex with
    value as key and insert as current vertexs left
    child
  • when value is greater, insert as current vertexs
    right child

4
Example 1
Enter the following values into a binary search
tree 14, 9, 26, 7, 12, 34, 5, 2, 16
5
Decision Trees
  • Rooted trees can be used to model problems in
    which a series of decisions leads to a solution
  • Each internal vertex is a decision point, and
    each leaf represents a possible outcome

6
Section 9.2
  • Tree Applications
Write a Comment
User Comments (0)
About PowerShow.com