Example #1
0
File: main.c Project: syvjohan/CFun
void postOrder(TreeNodePtr treePtr) {
    if (treePtr != NULL) {
        postOrder(treePtr->leftPtr);
        postOrder(treePtr->rightPtr);
        printf("%3d", treePtr->data);
    }
}
Example #2
0
void postOrder(node* ptr){
    if(ptr!=NULL){
        postOrder(ptr->left);
        postOrder(ptr->right);
        printf("%d ",ptr->data);
    }
}
Example #3
0
void BST<ItemType>::postOrder(TreeNode<ItemType> *t, ofstream &file)
{
    if(t == NULL) return;
    postOrder(t->right, file);
    postOrder(t->left, file);
    file << t->element << " ";
}
void BinaryTree<T>::postOrder(BinaryTree<T>* pNode) {
    if (pNode == 0)
        return;
    postOrder(pNode->left);
    postOrder(pNode->right);
    cout << pNode->data << endl;
}
Example #5
0
File: 51.cpp Project: hbdhj/c
void postOrder(node *root) {
    if (root) {
        postOrder(root->left);
        postOrder(root->right);
        cout << root->data << " ";
    }
}
Example #6
0
void Solution508::postOrder(TreeNode *root, unordered_map<int, int> &counter, int &maxCount)
{
    if (root == nullptr)
        return;

    if (root->left)
    {
        postOrder(root->left, counter, maxCount);
        root->val += root->left->val;
    }
    if (root->right)
    {
        postOrder(root->right, counter, maxCount);
        root->val += root->right->val;
    }

    int count = counter.count(root->val);
    if (count == 0)
    {
        counter.insert({root->val, 1});
        count = 1;
    } else
        count = ++ counter[root->val];
    maxCount = std::max(maxCount, count);
}
 void postOrder(TreeNode *root, vector<int>& ret) {
 	if(!root)
 		return ;
 	postOrder(root->left, ret);
 	postOrder(root->right, ret);
 	ret.push_back(root->val);
 }
void postOrder(BSTree *myTree) {
  if (myTree) {
    postOrder(myTree -> leftChild);
    postOrder(myTree -> rightChild);
    printf(" %d", myTree -> value);
  }
}
void postOrder(node *root) {
  if(root != NULL){
    postOrder(root->left);
    postOrder(root->right);
    cout << root->data << ' ';
  }
}
Example #10
0
void postOrder(struct node *root){
    if (root) {
        postOrder(root->left);
        postOrder(root->right);
        printf("%d ", root->key);
    }
}
Example #11
0
void postOrder(TreeNode *root,DISPLAY display){
    if(root != NULL){
        postOrder(root->left, display);
        postOrder(root->right, display);
        display(root->data);
    }
}
Example #12
0
/**
 * print the tree with postorder method
 * @param t
 */
void postOrder(tree t) {
    if (t) {
        postOrder(t->left);
        postOrder(t->right);
        printf("%d\n", t->elem);
    }
}
Example #13
0
void postOrder(Node * T)
{
	if (T->lchild!=NULL)
		postOrder(T->lchild);
	if (T->rchild!=NULL)
		postOrder(T->rchild);
	str[(*size)++]=T->c+'0';
}
Example #14
0
void	BinaryTree::postOrder(treeNode *root)
{
	if(root->leftChild)
		postOrder(root->leftChild);
	if(root->rightChild)
		postOrder(root->rightChild);
	std::cout<<root->data<<" ";
}
Example #15
0
void postOrder(struct node *n) {
  if (n == NULL)
    return;

  postOrder(n->left);
  postOrder(n->right);
  printf("%d ", n->key);
}
void BinarySearchTree<T>::postOrder(Node<T> *rootTree) const
{
    if (rootTree != nullptr) {
        postOrder(rootTree->leftChild);
        postOrder(rootTree->rightChild);
        std::cout << rootTree->data << " ";
    }
}
Example #17
0
void postOrder(PTreeNode pNode)
{
    if (pNode != NULL) {
        postOrder(pNode->left);
        postOrder(pNode->right);
        visit(pNode);
    }
}
Example #18
0
static void postOrder(RBTree rootNode) {
    if(rootNode)
    {
        postOrder(rootNode->lchild);
        postOrder(rootNode->rchild);
        printf("%d(%s) ",rootNode->key,(rootNode->color == RED?"红":"黑"));
    }
}
void postOrder(char t[][MAX_WORD_SIZE + 1], int root, int n)
{
    if (root <= n && strcmp(t[root], "*") != 0) {
        postOrder(t, root * 2, n);
        postOrder(t, root * 2 + 1, n);
        visit(t, root);
    }
}
Example #20
0
void postOrder(TNODE *node) {
	if (node == NULL) {
		return;
	}
	postOrder(node->leftChild);
	postOrder(node->rightChild);
	printf("%d ", node->value);
}
Example #21
0
void postOrder(BiTreeNode* tree)
{
	if (tree != NULL) {
		postOrder(tree->left);
		postOrder(tree->right);
		printf("%d ", tree->data);
	} // end if
} // end poseOrder()
Example #22
0
/**
 * Processes the TBST in post-order, applying the specified function at
 * each Node. Defaults to print(), starting at root.
 * 
 * @param func  function to apply to each Node pointer along the path.
 *              Design this function with only a single Node pointer in mind.
 * @param output    ostream object to append the output content to
 * @param cur   pointer to Node at which to process and start recursion on.
 */
void TBST::postOrder(void (*func)(Node*, ostream&), ostream& output, Node* cur) {
    if(cur != NULL) {
        if(cur->hasLeftChild())
            postOrder(func, output, cur->getLeft());
        if(cur->hasRightChild())
            postOrder(func, output, cur->getRight());
        func(cur, output);
    }
}
Example #23
0
/*** 后序遍历***/ 
void postOrder(BitTree* T)
{
	
	if(T){
		postOrder(T->lchild);
		postOrder(T->rchild);
		printf("%c ", T->data);	
	}
}
void postOrder(node *root) {
    if (root==NULL)
        return;
    
    postOrder(root->left);
    postOrder(root->right);
    cout << root->data << " ";

}
Example #25
0
/* begin postorder traversal of tree */
void postOrder( TreeNodePtr treePtr )
{ 
   /* if tree is not empty then traverse */
   if ( treePtr != NULL ) { 
      postOrder( treePtr->leftPtr );
      postOrder( treePtr->rightPtr );
      printf( "%3d", treePtr->data );
   } /* end if */
} /* end function postOrder */
Example #26
0
void postOrder(tree *p)
{
    if(*p)
    {
        postOrder(&(*p)->left);
        postOrder(&(*p)->rigth);
        show(&(*p)->info);
    }
}
void HashTable::postOrder(MovieNode *node) {
    if (node-> leftChild != NULL) {
		postOrder(node-> leftChild);
	}
	if (node-> rightChild != NULL) {
		postOrder(node-> rightChild);
	}
	std::cout << "Deleting: " << node-> title << std::endl;
	delete node;
}
void
postOrder(TreeNode* root)
{
	if (root)
	{
		postOrder(root->left);
		postOrder(root->right);
		std::cout<<root->val<<" ";
	}
}
Example #29
0
void BST::postOrder(BSTNode* root)
{
	if (root == NULL){
		return;
	}
	
	postOrder(root->left);
	postOrder(root->right);
	cout << root->value << " ";
}
Example #30
0
bool BTree<T>::postOrder(void (*visit) (BTreeNode<T>*), BTreeNode<T>* t)
{
	if (t)
	{
		postOrder(visit, t->left);
		postOrder(visit, t->right);
		visit(t);
	}

	return true;
}