6. 1 General Tree Definitions and Terminology Preorder traversals ABEFCDGHIJK BC Postorder traversals EF G EFBCIJKHGDA Level traversals ABCdEFGHIJK ①JK
A B C D E F G H I J K A B E F C D G H I J K E F B C I J K H G D A A B C D E F G H I J K Preorder traversals Level traversals Postorder traversals 6.1 General Tree Definitions and Terminology
6. 1 General Tree Definitions and Terminology General tree Traversal //Print using a preorder traversal void printhelp (gtnode<e>* root) i //访问根 if (root->isleafo) cout < leaf: else cout < Internal: out < root->value(<< " \n"; //从左到右访问各子树 for (gtnode<e> temp =root->leftmostchildo)i temp ! NULL temp temp->right sibling( printhelp ( temp)i A B
General Tree Traversal //Print using a preorder traversal void printhelp(GTNode<E>* root) { //访问根 if (root->isLeaf()) cout << "Leaf: "; else cout << "Internal: "; cout << root->value() << "\n"; //从左到右访问各子树 for (GTNode<E>* temp =root->leftmostChild(); temp != NULL; temp = temp->rightSibling()) printhelp(temp); } 6.1 General Tree Definitions and Terminology
Contents 6.1 General tree Definitions and Terminology 6.2 The Parent Pointer Implementation 6.3 General Tree Implementations 6.4 K-ary trees 6.5 Sequential Tree Implementations
Contents 6.1 General Tree Definitions and Terminology 6.2 The Parent Pointer Implementation 6.3 General Tree Implementations 6.4 K-ary Trees 6.5 Sequential Tree Implementations
6.2 The Parent Pointer Implementation 6.2 The parent pointer mplementation
14 6.2 The Parent Pointer Implementation 6.2 The Parent Pointer Implementation
6.2 The Parent Pointer Implementation Parent Pointer Implementation R W B Z ⊙( Parents Index 001112 7 LabelRABCDEFWXYZ Node|ndex012345678910
Parent Pointer Implementation 6.2 The Parent Pointer Implementation