Lecture 19 – November 2, 2006

 

Reviewed exam

    Spent time discussing how to trace a recursive program 

 

Reviewed queue linked list implementation – 12 points will be added to everyone’s score since FIRST was not specified as an operation to be implemented.

 

MEMORIZE

A binary tree  is either empty or it consists of a node called the root together with two binary trees called the left subtree  and the right subtree of the root.

 

MEMORIZE

A binary search tree is a binary tree that is either empty or in which each node contains a  value that satisfied the following conditions:

1.  All values (if any) in the left subtree of the root precede the value in the root.

2.  The value in the root precedes all of the values (if any) in the right subtree

3.  The left and right subtrees of the root are binary search trees.

 

We drew all the trees with

            One node                     2 nodes                        3 nodes                        4 nodes

 How many are there?  1            2                                   5                                  12

        

We examined the specification on pages 637 and 638 – will be discussed further

 

Pre-order Traversal:  visit the node, traverse its left subtree, traverse its right subtree

H  E  A  C  P  J  N  S  L  X  T  R

In-order Traversal:   traverse the self subtree, visit the node, traverse its right subtree

A  C  E  J  P  N  H  L  S  T  X  R

Post-order Traversal:  traverse the left subtree, traverse the right subtree, visit the node

C  A  J  N  P  E  L  T  R  X  S  H