 2003 Prentice Hall, Inc. All rights reserved. 1 20.5 Stacks Upcoming program –Create stack from list insertAtFront, removeFromFront –Software reusability.

Slides:



Advertisements
Similar presentations
 2000 Deitel & Associates, Inc. All rights reserved. Chapter 15 – Data Structures Outline 15.1Introduction 15.2Self-Referential Classes 15.3Dynamic Memory.
Advertisements

 2003 Prentice Hall, Inc. All rights reserved. 1 Chapter 20 – Data Structures Outline 20.1 Introduction 20.2 Self-Referential Classes 20.3 Dynamic Memory.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved L12 (Chapter 20) Lists, Stacks,
Chapter 12 C Data Structures Acknowledgment The notes are adapted from those provided by Deitel & Associates, Inc. and Pearson Education Inc.
 2000 Prentice Hall, Inc. All rights reserved. Chapter 22 - C++ Templates Outline 22.1Introduction 22.2Class Templates 22.3Class Templates and Non-type.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 12 – Data Structures Outline 12.1Introduction.
 2003 Prentice Hall, Inc. All rights reserved. 1 Chapter 11 - Templates Outline 11.1 Introduction 11.2 Function Templates 11.3 Overloading Function Templates.
 2003 Prentice Hall, Inc. All rights reserved. 1 Chapter 20 - Data Structures Outline 20.1 Introduction 20.2 Self-Referential Classes 20.3 Dynamic Memory.
Starting Out with C++: Early Objects 5/e © 2006 Pearson Education. All Rights Reserved Starting Out with C++: Early Objects 5 th Edition Chapter 19 Binary.
 2006 Pearson Education, Inc. All rights reserved Data Structures.
Templates Outlines 1. Introduction 2. Function Templates 3. Overloading Function Templates 4. Class Templates.
Helpful C++ Transitions
Data Structures Using C++1 Chapter 11 Binary Trees.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 122 – Data Structures Data Structures Trees.
Chapter 12 Data Structure Associate Prof. Yuh-Shyan Chen Dept. of Computer Science and Information Engineering National Chung-Cheng University.
 2003 Prentice Hall, Inc. All rights reserved Linked Lists Upcoming program has two class templates –Create two class templates –ListNode data.
Templates Zhen Jiang West Chester University
Data Structures Outline Introduction Self-Referential Classes Dynamic Memory Allocation Linked Lists Stacks Queues Trees.
 2003 Prentice Hall, Inc. All rights reserved. 1 Chapter 11 - Templates Outline 11.1 Introduction 11.2 Function Templates 11.3 Overloading Function Templates.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 122 – Data Structures Custom Templatized Data Structures.
1 Object-Oriented Programming -- Using C++ Andres, Wen-Yuan Liao Department of Computer Science and Engineering De Lin Institute of Technology
C++ How to Program, 7/e © by Pearson Education, Inc. All Rights Reserved.
 Pearson Education, Inc. All rights reserved Data Structures.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 122 – Data Structures Templatized Tree.
 2007 Pearson Education, Inc. All rights reserved C Data Structures.
Trees.ppt1 Introduction Many data structures are linear –unique first component –unique last component –other components have unique predecessor and successor.
1 CISC181 Introduction to Computer Science Dr. McCoy Lecture 22 November 17, 2009.
Data Structures Systems Programming. 22 Data Structures  Queues –Queuing System Models –Queue Data Structures –A Queue Example  Trees –Binary Trees.
 2002 Prentice Hall, Inc. All rights reserved. Chapter 19 – Data Structures Outline 19.1 Introduction 19.2 Self-Referential Classes 19.3 Dynamic Memory.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 122 – Data Structures Course Review FINAL.
 2000 Deitel & Associates, Inc. All rights reserved. Chapter 12 - Templates Outline 12.1Introduction 12.2Function Templates 12.3Overloading Template Functions.
 2003 Prentice Hall, Inc. All rights reserved. 1 Chapter 17 - Data Structures Outline 17.1 Introduction 17.2 Self-Referential Classes 17.3 Dynamic Memory.
 2003 Prentice Hall, Inc. All rights reserved. 1 IS 0020 Program Design and Software Tools Templates Lecture 10 March 23, 2004.
Programming Practice 3 - Dynamic Data Structure
Data Structures Systems Programming. Systems Programming: Data Structures 2 2 Systems Programming: 2 Data Structures  Queues –Queuing System Models –Queue.
Final Exam –Date: Aug 27 th –Time: 9:00am – 12:00pm –Location: TEL 0014.
Java How to Program, 9/e © Copyright by Pearson Education, Inc. All Rights Reserved.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 122 – Data Structures Templatized Stack.
TEMPLATESTEMPLATES BCAS,Bapatla B.mohini devi. Templates Outline 22.1Introduction 22.2Class Templates 22.3Class Templates and Non-type Parameters 22.4Templates.
Copyright © 2012 Pearson Education, Inc. Chapter 20: Binary Trees.
Copyright © 2015, 2012, 2009 Pearson Education, Inc., Publishing as Addison-Wesley All rights reserved. Chapter 20: Binary Trees.
Java How to Program, 10/e © Copyright by Pearson Education, Inc. All Rights Reserved.
 2000 Deitel & Associates, Inc. All rights reserved. 12.1Introduction Templates - easily create a large range of related functions or classes –function.
CS 240Chapter 10 – TreesPage Chapter 10 Trees The tree abstract data type provides a hierarchical to the representation of certain types of relationships.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 122 – Data Structures Templatized Queue.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 20: Binary Trees.
 2003 Prentice Hall, Inc. All rights reserved. 1 Ders Notu 8 - Template İçerik 11.1 Giriş 11.2 Fonksiyon Template ları 11.3 Overloading Fonksiyon Templates.
1 Binary Search Trees. 2 Binary Search Trees Binary Search Trees The Binary Search Tree (BST) Search, Insertion and Traversal of BST Removal of nodes.
Chapter 20 Custom Templatized Data Structures
Chapter 22 - C++ Templates
Chapter 12 – Data Structures
12 C Data Structures.
Chapter 22 Custom Generic Data Structures
Intro to Data Structures
Chapter 20: Binary Trees.
Helpful C++ Transitions
Chapter 21: Binary Trees.
Chapter 19 – Data Structures
Chapter 11 - Templates Outline Introduction Function Templates Overloading Function Templates Class Templates Class.
20.5 Stacks Upcoming program Create stack from list
Chapter 11 - Templates Outline Introduction Function Templates Overloading Function Templates Class Templates Class.
Pointers & Dynamic Data Structures
template< class T > class Stack { public:
Chapter 20: Binary Trees.
Chapter 11 - Templates Outline Introduction Function Templates Overloading Function Templates Class Templates Class.
Chapter 22 - C++ Templates
Chapter 22 - C++ Templates
Chapter 20 - Data Structures
Chapter 11 - Templates Outline Introduction Function Templates Overloading Function Templates Class Templates Class.
Presentation transcript:

 2003 Prentice Hall, Inc. All rights reserved Stacks Upcoming program –Create stack from list insertAtFront, removeFromFront –Software reusability Inheritance –Stack inherits from List Composition –Stack contains a private List object –Performs operations on that object –Makes stack implementation simple

 2003 Prentice Hall, Inc. All rights reserved. Outline 2 stack.h (1 of 2) 1 // Fig : stack.h 2 // Template Stack class definition derived from class List. 3 #ifndef STACK_H 4 #define STACK_H 5 6 #include "list.h" // List class definition 7 8 template 9 class Stack : private List { public: 12 // push calls List function insertAtFront 13 void push( const STACKTYPE &data ) 14 { 15 insertAtFront( data ); } // end function push // pop calls List function removeFromFront 20 bool pop( STACKTYPE &data ) 21 { 22 return removeFromFront( data ); } // end function pop 25 Stack inherits from List.Define push and pop, which call insertAtFront and removeFromFront.

 2003 Prentice Hall, Inc. All rights reserved. Outline 3 stack.h (2 of 2) 26 // isStackEmpty calls List function isEmpty 27 bool isStackEmpty() const 28 { 29 return isEmpty(); } // end function isStackEmpty // printStack calls List function print 34 void printStack() const 35 { 36 print(); } // end function print }; // end class Stack #endif

 2003 Prentice Hall, Inc. All rights reserved. Outline 4 fig17_11.cpp (1 of 3) 1 // Fig : fig17_11.cpp 2 // Template Stack class test program. 3 #include 4 5 using std::endl; 6 7 #include "stack.h" // Stack class definition 8 9 int main() 10 { 11 Stack intStack; // create Stack of ints cout << "processing an integer Stack" << endl; // push integers onto intStack 16 for ( int i = 0; i < 4; i++ ) { 17 intStack.push( i ); 18 intStack.printStack(); } // end for // pop integers from intStack 23 int popInteger; 24

 2003 Prentice Hall, Inc. All rights reserved. Outline 5 fig17_11.cpp (2 of 3) 25 while ( !intStack.isStackEmpty() ) { 26 intStack.pop( popInteger ); 27 cout << popInteger << " popped from stack" << endl; 28 intStack.printStack(); } // end while Stack doubleStack; // create Stack of doubles 33 double value = 1.1; cout << "processing a double Stack" << endl; // push floating-point values onto doubleStack 38 for ( int j = 0; j< 4; j++ ) { 39 doubleStack.push( value ); 40 doubleStack.printStack(); 41 value += 1.1; } // end for 44

 2003 Prentice Hall, Inc. All rights reserved. Outline 6 fig17_11.cpp (3 of 3) 45 // pop floating-point values from doubleStack 46 double popDouble; while ( !doubleStack.isStackEmpty() ) { 49 doubleStack.pop( popDouble ); 50 cout << popDouble << " popped from stack" << endl; 51 doubleStack.printStack(); } // end while return 0; } // end main

 2003 Prentice Hall, Inc. All rights reserved. Outline 7 fig17_11.cpp output (1 of 2) processing an integer Stack The list is: 0 The list is: 1 0 The list is: The list is: popped from stack The list is: popped from stack The list is: popped from stack The list is: 0 0 popped from stack The list is empty processing a double Stack The list is: 1.1 The list is: The list is:

 2003 Prentice Hall, Inc. All rights reserved. Outline 8 fig17_11.cpp output (2 of 2) The list is: popped from stack The list is: popped from stack The list is: popped from stack The list is: popped from stack The list is empty All nodes destroyed All nodes destroyed

 2003 Prentice Hall, Inc. All rights reserved. Outline 9 stackcomposition.h (1 of 2) 1 // Fig : stackcomposition.h 2 // Template Stack class definition with composed List object. 3 #ifndef STACKCOMPOSITION 4 #define STACKCOMPOSITION 5 6 #include "list.h" // List class definition 7 8 template 9 class Stack { public: 12 // no constructor; List constructor does initialization // push calls stackList object's insertAtFront function 15 void push( const STACKTYPE &data ) 16 { 17 stackList.insertAtFront( data ); } // end function push // pop calls stackList object's removeFromFront function 22 bool pop( STACKTYPE &data ) 23 { 24 return stackList.removeFromFront( data ); } // end function pop 27 Alternative implementation of stack.h, using composition. Declare a private List member, use to manipulate stack.

 2003 Prentice Hall, Inc. All rights reserved. Outline 10 stackcomposition.h (2 of 2) 28 // isStackEmpty calls stackList object's isEmpty function 29 bool isStackEmpty() const 30 { 31 return stackList.isEmpty(); } // end function isStackEmpty // printStack calls stackList object's print function 36 void printStack() const 37 { 38 stackList.print(); } // end function printStack private: 43 List stackList; // composed List object }; // end class Stack #endif

 2003 Prentice Hall, Inc. All rights reserved Queues Queue –Like waiting in line –Nodes added to back (tail), removed from front (head) –First-in, first-out (FIFO) data structure –Insert/remove called enqueue/dequeue Applications –Print spooling Documents wait in queue until printer available –Packets on network –File requests from server

 2003 Prentice Hall, Inc. All rights reserved Queues Upcoming program –Queue implementation –Reuse List as before insertAtBack ( enqueue ) removeFromFront ( dequeue )

 2003 Prentice Hall, Inc. All rights reserved. Outline 13 queue.h (1 of 2) 1 // Fig : queue.h 2 // Template Queue class definition derived from class List. 3 #ifndef QUEUE_H 4 #define QUEUE_H 5 6 #include "list.h" // List class definition 7 8 template 9 class Queue : private List { public: 12 // enqueue calls List function insertAtBack 13 void enqueue( const QUEUETYPE &data ) 14 { 15 insertAtBack( data ); } // end function enqueue // dequeue calls List function removeFromFront 20 bool dequeue( QUEUETYPE &data ) 21 { 22 return removeFromFront( data ); } // end function dequeue 25 Inherit from template class List. Reuse the appropriate List functions.

 2003 Prentice Hall, Inc. All rights reserved. Outline 14 queue.h (2 of 2) 26 // isQueueEmpty calls List function isEmpty 27 bool isQueueEmpty() const 28 { 29 return isEmpty(); } // end function isQueueEmpty // printQueue calls List function print 34 void printQueue() const 35 { 36 print(); } // end function printQueue }; // end class Queue #endif

 2003 Prentice Hall, Inc. All rights reserved. Outline 15 fig17_14.cpp (1 of 3) 1 // Fig : fig17_14.cpp 2 // Template Queue class test program. 3 #include 4 5 using std::endl; 6 7 #include "queue.h" // Queue class definition 8 9 int main() 10 { 11 Queue intQueue; // create Queue of ints cout << "processing an integer Queue" << endl; // enqueue integers onto intQueue 16 for ( int i = 0; i < 4; i++ ) { 17 intQueue.enqueue( i ); 18 intQueue.printQueue(); } // end for // dequeue integers from intQueue 23 int dequeueInteger; 24

 2003 Prentice Hall, Inc. All rights reserved. Outline 16 fig17_14.cpp (2 of 3) 25 while ( !intQueue.isQueueEmpty() ) { 26 intQueue.dequeue( dequeueInteger ); 27 cout << dequeueInteger << " dequeued" << endl; 28 intQueue.printQueue(); } // end while Queue doubleQueue; // create Queue of doubles 33 double value = 1.1; cout << "processing a double Queue" << endl; // enqueue floating-point values onto doubleQueue 38 for ( int j = 0; j< 4; j++ ) { 39 doubleQueue.enqueue( value ); 40 doubleQueue.printQueue(); 41 value += 1.1; } // end for 44

 2003 Prentice Hall, Inc. All rights reserved. Outline 17 fig17_14.cpp (3 of 3) 45 // dequeue floating-point values from doubleQueue 46 double dequeueDouble; while ( !doubleQueue.isQueueEmpty() ) { 49 doubleQueue.dequeue( dequeueDouble ); 50 cout << dequeueDouble << " dequeued" << endl; 51 doubleQueue.printQueue(); } // end while return 0; } // end main

 2003 Prentice Hall, Inc. All rights reserved. Outline 18 fig17_14.cpp output (1 of 2) processing an integer Queue The list is: 0 The list is: 0 1 The list is: The list is: dequeued The list is: dequeued The list is: dequeued The list is: 3 3 dequeued The list is empty processing a double Queue The list is: 1.1 The list is:

 2003 Prentice Hall, Inc. All rights reserved. Outline 19 fig17_14.cpp output (2 of 2) The list is: The list is: dequeued The list is: dequeued The list is: dequeued The list is: dequeued The list is empty All nodes destroyed All nodes destroyed

 2003 Prentice Hall, Inc. All rights reserved Trees Linear data structures –Lists, queues, stacks Trees –Nonlinear, two-dimensional –Tree nodes have 2 or more links –Binary trees have exactly 2 links/node None, both, or one link can be null

 2003 Prentice Hall, Inc. All rights reserved Trees Terminology –Root node: first node on tree –Link refers to child of node Left child is root of left subtree Right child is root of right subtree –Leaf node: node with no children –Trees drawn from root downwards B A D C

 2003 Prentice Hall, Inc. All rights reserved Trees Binary search tree –Values in left subtree less than parent node –Values in right subtree greater than parent Does not allow duplicate values (good way to remove them) –Fast searches, log 2 n comparisons for a balanced tree

 2003 Prentice Hall, Inc. All rights reserved Trees Inserting nodes –Use recursive function –Begin at root –If current node empty, insert new node here (base case) –Otherwise, If value > node, insert into right subtree If value < node, insert into left subtree If neither > nor <, must be = –Ignore duplicate

 2003 Prentice Hall, Inc. All rights reserved Trees Tree traversals –In-order (print tree values from least to greatest) Traverse left subtree (call function again) Print node Traverse right subtree –Preorder Print node Traverse left subtree Traverse right subtree –Postorder Traverse left subtree Traverse rigth subtree Print node

 2003 Prentice Hall, Inc. All rights reserved Trees Upcoming program –Create 2 template classes –TreeNode data leftPtr rightPtr –Tree rootPtr Functions –InsertNode –inOrderTraversal –preOrderTraversal –postOrderTraversal

 2003 Prentice Hall, Inc. All rights reserved. Outline 26 treenode.h (1 of 2) 1 // Fig : treenode.h 2 // Template TreeNode class definition. 3 #ifndef TREENODE_H 4 #define TREENODE_H 5 6 // forward declaration of class Tree 7 template class Tree; 8 9 template 10 class TreeNode { 11 friend class Tree ; public: // constructor 16 TreeNode( const NODETYPE &d ) 17 : leftPtr( 0 ), 18 data( d ), 19 rightPtr( 0 ) 20 { 21 // empty body } // end TreeNode constructor 24 Binary trees have two pointers.

 2003 Prentice Hall, Inc. All rights reserved. Outline 27 treenode.h (2 of 2) 25 // return copy of node's data 26 NODETYPE getData() const 27 { 28 return data; } // end getData function private: 33 TreeNode *leftPtr; // pointer to left subtree 34 NODETYPE data; 35 TreeNode *rightPtr; // pointer to right subtree }; // end class TreeNode #endif

 2003 Prentice Hall, Inc. All rights reserved. Outline 28 tree.h (1 of 6) 1 // Fig : tree.h 2 // Template Tree class definition. 3 #ifndef TREE_H 4 #define TREE_H 5 6 #include 7 8 using std::endl; 9 10 #include 11 #include "treenode.h" template 14 class Tree { public: 17 Tree(); 18 void insertNode( const NODETYPE & ); 19 void preOrderTraversal() const; 20 void inOrderTraversal() const; 21 void postOrderTraversal() const; private: 24 TreeNode *rootPtr; 25

 2003 Prentice Hall, Inc. All rights reserved. 29 Review – Pass-by-Reference Pass-by-Reference with reference arguments function call: DataType x; … f ( x ); function definition: DataType f (DataType & y) {…} // y is an alias of x Pass-by-Reference with pointer arguments function call: DataType x; … f (&x); function definition: DataType f (Datatype * y) {…} // *y is an alias of x Important purpose: x value changes as y or *y changes

 2003 Prentice Hall, Inc. All rights reserved. Outline 30 tree.h (2 of 6) 26 // utility functions 27 void insertNodeHelper( 28 TreeNode **, const NODETYPE & ); 29 void preOrderHelper( TreeNode * ) const; 30 void inOrderHelper( TreeNode * ) const; 31 void postOrderHelper( TreeNode * ) const; }; // end class Tree // constructor 36 template 37 Tree ::Tree() 38 { 39 rootPtr = 0; } // end Tree constructor // insert node in Tree 44 template 45 void Tree ::insertNode( const NODETYPE &value ) 46 { 47 insertNodeHelper( &rootPtr, value ); 48 } // end function insertNode

 2003 Prentice Hall, Inc. All rights reserved. Outline 31 tree.h (3 of 6) 51 /* utility function called by insertNode; receives a pointer (ptr) 52 to a pointer (rootPtr) so that the function can modify pointer's value (i.e. rootPtr’s value) through modifying *ptr */ 53 template 54 void Tree ::insertNodeHelper( 55 TreeNode **ptr, const NODETYPE &value ) 56 { 57 // subtree is empty; create new TreeNode containing value 58 if ( *ptr == 0 ) 59 *ptr = new TreeNode ( value ); else // subtree is not empty // data to insert is less than data in current node 64 if ( value data ) 65 insertNodeHelper( &( ( *ptr )->leftPtr ), value ); else // data to insert is greater than data in current node 70 if ( value > ( *ptr )->data ) 71 insertNodeHelper( &( ( *ptr )->rightPtr ), value ); else // duplicate data value ignored 74 cout << value << " dup" << endl; } // end function insertNodeHelper Recursive function to insert a new node. If the current node is empty, insert the new node here. If new value greater than current node ( ptr ), insert into right subtree. If less, insert into left subtree. If neither case applies, node is a duplicate -- ignore.

 2003 Prentice Hall, Inc. All rights reserved. Outline 32 tree.h (4 of 6) // begin preorder traversal of Tree 79 template 80 void Tree ::preOrderTraversal() const 81 { 82 preOrderHelper( rootPtr ); } // end function preOrderTraversal // utility function to perform preorder traversal of Tree 87 template 88 void Tree ::preOrderHelper( 89 TreeNode *ptr ) const 90 { 91 if ( ptr != 0 ) { 92 cout data << ' '; // process node 93 preOrderHelper( ptr->leftPtr ); // go to left subtree 94 preOrderHelper( ptr->rightPtr ); // go to right subtree } // end if } // end function preOrderHelper 99 Preorder: print, left, right

 2003 Prentice Hall, Inc. All rights reserved. Outline 33 tree.h (5 of 6) 100 // begin inorder traversal of Tree 101 template 102 void Tree ::inOrderTraversal() const 103 { 104 inOrderHelper( rootPtr ); } // end function inOrderTraversal // utility function to perform inorder traversal of Tree 109 template 110 void Tree ::inOrderHelper( 111 TreeNode *ptr ) const 112 { 113 if ( ptr != 0 ) { 114 inOrderHelper( ptr->leftPtr ); // go to left subtree 115 cout data << ' '; // process node 116 inOrderHelper( ptr->rightPtr ); // go to right subtree } // end if } // end function inOrderHelper 121 In order: left, print, right

 2003 Prentice Hall, Inc. All rights reserved. Outline 34 tree.h (6 of 6) 122 // begin postorder traversal of Tree 123 template 124 void Tree ::postOrderTraversal() const 125 { 126 postOrderHelper( rootPtr ); } // end function postOrderTraversal // utility function to perform postorder traversal of Tree 131 template 132 void Tree ::postOrderHelper( 133 TreeNode *ptr ) const 134 { 135 if ( ptr != 0 ) { 136 postOrderHelper( ptr->leftPtr ); // go to left subtree 137 postOrderHelper( ptr->rightPtr ); // go to right subtree 138 cout data << ' '; // process node } // end if } // end function postOrderHelper #endif Postorder: left, right, print

 2003 Prentice Hall, Inc. All rights reserved. Outline 35 fig17_19.cpp (1 of 3) 1 // Fig : fig17_19.cpp 2 // Tree class test program. 3 #include 4 5 using std::cout; 6 using std::cin; 7 using std::fixed; 8 9 #include 10 using std::setprecision; #include "tree.h" // Tree class definition int main() 15 { 16 Tree intTree; // create Tree of int values 17 int intValue; cout << "Enter 10 integer values:\n"; for( int i = 0; i < 10; i++ ) { 22 cin >> intValue; 23 intTree.insertNode( intValue ); } // end for

 2003 Prentice Hall, Inc. All rights reserved. Outline 36 fig17_19.cpp (2 of 3) cout << "\nPreorder traversal\n"; 28 intTree.preOrderTraversal(); cout << "\nInorder traversal\n"; 31 intTree.inOrderTraversal(); cout << "\nPostorder traversal\n"; 34 intTree.postOrderTraversal(); Tree doubleTree; // create Tree of double values 37 double doubleValue; cout << fixed << setprecision( 1 ) 40 << "\n\n\nEnter 10 double values:\n"; for ( int j = 0; j < 10; j++ ) { 43 cin >> doubleValue; 44 doubleTree.insertNode( doubleValue ); } // end for cout << "\nPreorder traversal\n"; 49 doubleTree.preOrderTraversal(); 50

 2003 Prentice Hall, Inc. All rights reserved. Outline 37 fig17_19.cpp (3 of 3) 51 cout << "\nInorder traversal\n"; 52 doubleTree.inOrderTraversal(); cout << "\nPostorder traversal\n"; 55 doubleTree.postOrderTraversal(); cout << endl; return 0; } // end main

 2003 Prentice Hall, Inc. All rights reserved. Outline 38 fig17_19.cpp output (1 of 1) Enter 10 integer values: Preorder traversal Inorder traversal Postorder traversal Enter 10 double values: Preorder traversal Inorder traversal Postorder traversal