Esempio n. 1
0
void Tree::preOrder(Node *node) {
    if (node) {
        preOrder(node->left());
        this->visit(node);
        preOrder(node->right());
    }
}
Esempio n. 2
0
void preOrder(node *root) {
	if(root == NULL) return;

	printf("%d\t", root->key);
	preOrder(root->left);
	preOrder(root->right);
}
Esempio n. 3
0
void BTree::preOrder(tree *temp){
	if(temp!=NULL){
		cout<<temp->data<<" ";
		preOrder(temp->left);
		preOrder(temp->right);
	}
}
void preOrder(BSTree *myTree) {
  if (myTree) {
    printf(" %d", myTree -> value);
    preOrder(myTree -> leftChild);
    preOrder(myTree -> rightChild);
  }
}
Esempio n. 5
0
void preOrder(node* ptr){
    if(ptr!=NULL){
        printf("%d ",ptr->data);
        preOrder(ptr->left);
        preOrder(ptr->right);
    }
}
Esempio n. 6
0
void preOrder(node* root)
{
	if(root == NULL)
		return ;
	printf("%s %d %d\n" , root->key , root->ht , getBalance(root)) ;
	preOrder(root->lc) ;
	preOrder(root->rc) ;
}
void preOrder(struct TNode* root)
{
    if (root == NULL)
        return ;
    printf("%d ", root->data);
    preOrder(root->left);
    preOrder(root->right);
}
Esempio n. 8
0
static void preOrder(RBTree rootNode) {
    if(rootNode)
    {
        printf("%d(%s) ",rootNode->key,(rootNode->color == RED?"红":"黑"));
        preOrder(rootNode->lchild);
        preOrder(rootNode->rchild);
    }
}
Esempio n. 9
0
void preOrder(BINTREENODE *root)
{
	if (root != NULL) {
		printf("%c ", root->data);
		preOrder(root->left);
		preOrder(root->right);
	}
}
void BinarySearchTree<T>::preOrder(Node<T> *rootTree) const
{
    if (rootTree != nullptr) {
        std::cout << rootTree->data << " ";
        preOrder(rootTree->leftChild);
        preOrder(rootTree->rightChild);
    }
}
Esempio n. 11
0
void preOrder(struct node *root){
	if(root == NULL)
		return;
		
	printf("%d ", root->data);
	preOrder(root->lptr);
	preOrder(root->rptr);
}
Esempio n. 12
0
void preOrder(PTreeNode pNode)
{
    if (pNode != NULL) {
        visit(pNode);
        preOrder(pNode->left);
        preOrder(pNode->right);
    }
}
Esempio n. 13
0
void TwoThreeTree::preOrder(TNode *r) {
    if (r == NULL) return;

    r->print();
    preOrder(r->left);
    preOrder(r->middle);
    preOrder(r->right);
}
Esempio n. 14
0
void preOrder(TNODE *node) {
	if (node == NULL) {
		return;
	}
	printf("%d ", node->value);
	preOrder(node->leftChild);
	preOrder(node->rightChild);
}
Esempio n. 15
0
/* A utility function to print preorder traversal of BST */
void preOrder(struct Node* node)
{
    if (node == NULL)
        return;
    printf("%d ", node->data);
    preOrder(node->prev);
    preOrder(node->next);
}
Esempio n. 16
0
void preOrder(struct node *n) {
  if (n == NULL)
    return;

  printf("%d ", n->key);
  preOrder(n->left);
  preOrder(n->right);
}
Esempio n. 17
0
//先序递归遍历二叉树
void preOrder(BiTree root)
{   
    if(root){
        printf("%c ",root->data);
        preOrder(root->lchild);
        preOrder(root->rchild);
    }
}
Esempio n. 18
0
/*** 前序遍历***/ 
void preOrder(BitTree* T)
{
	if(T){				//不要忘记判断 T 
		printf("%c ", T->data);
		preOrder(T->lchild);
		preOrder(T->rchild);
	}
}
/*Bianry Search Tree 前序遍历递归实现*/
void preOrder(BinaryTree btree, Status(*visit)(BinaryTree)) {
	if (btree != NULL)
	{
		visit(btree);
		preOrder(btree->lchild, visit);
		preOrder(btree->rchild, visit);
	}

}
Esempio n. 20
0
/**
 * Processes the TBST in pre-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
 *              traversal path.
 * @param output    ostream object to append the output content to
 *              Design this function with only a single Node pointer in mind.
 * @param cur   pointer to Node at which to process and start recursion on.
 */
void TBST::preOrder(void (*func)(Node*, ostream&), ostream& output, Node* cur) {
    if(cur != NULL) {
        func(cur, output);
        if(cur->hasLeftChild())
            preOrder(func, output, cur->getLeft());
        if(cur->hasRightChild())
            preOrder(func, output, cur->getRight());
    }
}
Esempio n. 21
0
// A utility function to print preorder traversal of
// the tree.
// The function also prints height of every node
void preOrder(struct Node *root)
{
    if(root != NULL)
    {
        printf("%d ", root->key);
        preOrder(root->left);
        preOrder(root->right);
    }
}
Esempio n. 22
0
void preOrder(HuffmanNode* currentNode, map<int, string>& encodingMap, std::string coding = std::string()) {
    // if leaf, insert the current coding along with the character into the encodingmap.
    if (currentNode->isLeaf()) {
        encodingMap.insert(make_pair(currentNode->character, coding));
    } else {
        preOrder(currentNode->zero, encodingMap, coding + "0");
        preOrder(currentNode->one, encodingMap, coding + "1");
    }
}
Esempio n. 23
0
void preOrder(node * i_root)
{
    if (i_root)
    {
        cout << i_root->data << " ";
        preOrder(i_root->left);
        preOrder(i_root->right);        
    }
}
Esempio n. 24
0
void preOrder(Btree btree)
{
    if(btree->data)
        printf("%d\t",btree->data);
    if(btree->lchild)
        preOrder(btree->lchild);
    if(btree->rchild)
        preOrder(btree->rchild);
}
Esempio n. 25
0
/* begin preorder traversal of tree */
void preOrder( TreeNodePtr treePtr )
{ 
   /* if tree is not empty then traverse */
   if ( treePtr != NULL ) { 
      printf( "%3d", treePtr->data );
      preOrder( treePtr->leftPtr );
      preOrder( treePtr->rightPtr );
   } /* end if */
} /* end function preOrder */
Esempio n. 26
0
void preOrder(tree *p)
{
    if(*p)
    {
        show(&(*p)->info);
        preOrder(&(*p)->left);
        preOrder(&(*p)->rigth);
    }
}
Esempio n. 27
0
void preOrder(Tree *root)
{
    if (root != NULL)
    {
        printf("%d\n", root->val);
        preOrder(root->left);
        preOrder(root->right);
    }
}
Esempio n. 28
0
void preOrder(Arbol *p,FILE **fp)
{
    if(*p)
    {
        showInfoByKey(fp,(*p)->reg);
        preOrder(&(*p)->left,fp);
        preOrder(&(*p)->rigth,fp);
    }
}
Esempio n. 29
0
void preOrder(node *root) {
    printf("%d ", root->data);
    if (root->left) {
        preOrder(root->left);
    }
    if (root->right) {
        preOrder(root->right);
    }
}
Esempio n. 30
0
//先序遍历二叉树
void preOrder(const struct btree *ptr_root)
{	
	if(ptr_root!=NULL){
		struct	my_btree *node=btree_entry(ptr_root,struct my_btree,root);
		printf("%c ",node->data);
		preOrder(ptr_root->lchild);
		preOrder(ptr_root->rchild); 
	}
}