正在加载图片...
Inorder traversal: 调田递旧由序 递归中序遍历函数 template <class Entry> 多一个参数 void Binary-treeEntry?:inorder(void (*visit)(Er &) i recursive inorder (root, visit);] template <class Entry> void Binary_treEntry> recursive inorder(Binary node< Entry> *sub root, void visit)(Entry &) / Pre: sub_ root is either NULL or points to a subtree of the inary_tree Post: The subtree has been traversed in inorder sequence. * Iif (sub root E NULL i recursive inorder(sub root->left, visit) Visit)(sub root->data); recursive_inorder(sub root->right, visit);template <class Entry> void Binary_tree<Entry>::inorder(void (*visit)(Entry &)) { recursive_inorder(root, visit); } template <class Entry> void Binary_tree<Entry>:: recursive_inorder(Binary_node<Entry> *sub_root, void (*visit)(Entry &)) /* Pre: sub_root is either NULL or points to a subtree of the inary_tree. Post: The subtree has been traversed in inorder sequence. */ { if (sub_root != NULL) { recursive_inorder(sub_root->left, visit); (*visit)(sub_root->data); recursive_inorder(sub_root->right, visit); } } Inorder traversal: method 函数参数 (访问数据) 调用递归中序 递归中序遍历函数 遍历函数 多一个参数
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有