text cover

Data Abstraction and Problem Solving with C++

Walls and Mirrors

by Frank M. Carrano

Addison Wesley Logo

example534.cpp

Go to the documentation of this file.
00001 
00015 #include <iostream>
00016 #include "BinaryTree.h"  // binary tree operations
00017 
00018 using namespace std;
00019 
00020 void display(TreeItemType& anItem);
00021 
00022 int main()
00023 {
00024    BinaryTree tree1, tree2, left; // empty trees
00025    BinaryTree tree3(70);    // tree with only a root 70
00026 
00027 // build the tree in Figure 10-10
00028    tree1.setRootData(40);
00029    tree1.attachLeft(30);
00030    tree1.attachRight(50);
00031 
00032    tree2.setRootData(20);
00033    tree2.attachLeft(10);
00034    tree2.attachRightSubtree(tree1);
00035 
00036    // tree in Fig 10-10
00037    BinaryTree binTree(60, tree2, tree3);
00038 
00039    binTree.inorderTraverse(display);
00040    binTree.getLeftSubtree().inorderTraverse(display);
00041    binTree.detachLeftSubtree(left);
00042    left.inorderTraverse(display);
00043    binTree.inorderTraverse(display);
00044 
00045    return 0;
00046 }  // end main

Generated on Sun Aug 27 21:29:16 2006 for AWLogo by  doxygen 1.4.6