Beispiel #1
0
// 中序遍历递归 
void InOrder(pBTNode pRoot)
{
	if (pRoot) {
		InOrder(pRoot->_pLeft);
		printf("%c ", pRoot->_data);
		InOrder(pRoot->_pRight);
	}
}
Beispiel #2
0
void InOrder(int r)
{
  if(!r)return;
  push_down(r);
  InOrder(ch[r][0]);
  printf("%d ",key[r]);
  InOrder(ch[r][1]);
}
Beispiel #3
0
void InOrder(NodeTree* ApT) {

    if(ApT != NULL) {
        InOrder(ApT->left);
        Visit(ApT->info);
        InOrder(ApT->right);
    }
}
Beispiel #4
0
void Node::InOrder(Node *a) {
	if (a != NULL)
	{
		InOrder(a->left);
		std::cout << a->key << " ";
		InOrder(a->right);
	}
};
Beispiel #5
0
void InOrder(BinaryTreeNode<T> *t)
{// Inorder traversal of *t.
   if (t) {
      InOrder(t->LeftChild);   // do left subtree
      Visit(t);                // visit tree root
      InOrder(t->RightChild);  // do right subtree
      }
}
void InOrder(Tree Root)		//InOrder Traversal
{
	if (Root !=NULL)
	{
		InOrder(Root->Left);
		printf("%c",Root->data);
		InOrder(Root->Right);
	}
}
Beispiel #7
0
void InOrder(BiTree *&T)
{
	if(T!=NULL)
	{
		InOrder(T->lchild );
		printf("%c",T->data );
		InOrder(T->rchild );
	}
}
void  BinaryST<T>::InOrder(BSTNode<T> *ptr)
{
	if (ptr == NULL)
		return;

	InOrder(ptr->lC);
	cout << ptr->data.key << "(" << ptr->data.val << ")" << " ";
	InOrder(ptr->rC);
}
void InOrder(BiTree *bt)
{
	if (bt != NULL)
	{
		InOrder(bt->lchild);
		printf("%c", bt->data);
		InOrder(bt->rchild);
	}
}
Beispiel #10
0
void BinarySearchTree<Key, Value>::InOrder (BSTnode* subtree, Visit& visitor)
{
    if (subtree!=NULL)
    {
        InOrder(subtree->m_left, visitor);
        visitor(subtree->m_value);
        InOrder(subtree->m_right, visitor);
    }
}
void  BinaryST<T>::InOrder(BSTNode<T> *ptr)  {
	Item item;
	if(ptr == NULL)
		return;
	InOrder(ptr->lC);
	item = ptr->data;
	cout << item.key << "(" << item.val << ") ";
	InOrder(ptr->rC);
}
Beispiel #12
0
void InOrder(BTree *p)	//中序遍历BST
{
	if (p!=NULL) 
	{
		InOrder(p->lchild);					//中序遍历左子树
		printf("  %c(%d)\n",p->ch,p->count);//访问根结点
		InOrder(p->rchild);					//中序遍历右子树
	}
}
Beispiel #13
0
//中序遍历
void InOrder(BiTree T)
{
     if(T!=NULL)
     {
        InOrder(T->lchild);
        Visit(T);
        InOrder(T->rchild);
     }
}
Beispiel #14
0
void InOrder(Btree *root)
{
	if(root != NULL)
	{
		InOrder(root->left);
		printf("%d\n",root-data);
		InOrder(root->right);
	}
}
Beispiel #15
0
//从左子节点开始遍历树
static void InOrder(const Node * root,void (* pfun)(Item item))
{
	if(root != NULL)
	{
		InOrder(root->left,pfun);
		TraverseQueue(root->queue,pfun);
		InOrder(root->right,pfun);
	}
}
Beispiel #16
0
static void InOrder(const Node * root,void(* pfun)(Item item))
{
	if(root != NULL)
	{
		(*pfun)(root->item);
		InOrder(root->left,pfun);
		InOrder(root->right,pfun);
	}
}
Beispiel #17
0
void InOrder(treeNode* root)    // 중위 순회
{
  if(root!=NULL)
  {
    InOrder(root->left);    // Left Node Move
    printf("%c  ",root->data);  // Data Read
    InOrder(root->right);   // Right Node Move
  }
}
Beispiel #18
0
// 中序递归遍历
void RecurseInOrder(TreeNode *root)
{
	if(root)
    {
        InOrder(root->leftchild);
        std::cout << root->data << " ";
        InOrder(root->rightchild);
    }
}
Beispiel #19
0
// To get ascending order, do an in-order traversal of the tree
void BST::InOrder(BasePtr Item)
{  if ( !Item ) return;                // I.e., NULL tree

   InOrder(Item->Left);                // Process Left sub-tree
   cout << setw(4) << Item->Data       // Process this node
        << '(' << Item->Height << ')';
   if ( ++Nitems % 10 == 0 )
      cout.put('\n');
   InOrder(Item->Right);               // Process Right sub-tree
}
Beispiel #20
0
/**
 * This function is not right
 */
void InOrder(TBSTree tr) {
	if (!tr) 
		return;

	if (tr->leftthread == 0)
		InOrder(tr->left);
	printf("%p\t%d\n", tr, tr->elem);
	if (tr->rightthread == 0)
		InOrder(tr->right);
}
string BSTree::InOrder(BSTNode* node) {
    stringstream ss;
    string q;
    if(node != NULL) {
        q = InOrder(node->left_child());
        ss << q << node->contents() << " ";
        ss << InOrder(node->right_child());
    }
    return ss.str();
}
Beispiel #22
0
void  InOrder(BitTree root)  
/*中序遍历二叉树, root为指向二叉树(或某一子树)根结点的指针*/
{
 if (root!=NULL)
 {
  InOrder(root ->LChild);   /*中序遍历左子树*/
  Visit(root ->data);        /*访问根结点*/
  InOrder(root ->RChild);   /*中序遍历右子树*/
 }
}
Beispiel #23
0
void InOrder(TreeNode* tree, 
     QueType& inQue)
// Post: inQue contains the tree items in inorder.
{
  if (tree != NULL)
  {
    InOrder(tree->left, inQue);
    inQue.Enqueue(tree->info);
    InOrder(tree->right, inQue);
  }
}
Beispiel #24
0
string BSTree::InOrder(BSTNode* order)
{
    stringstream ss;
    if(order!=NULL)
    {
        ss<<InOrder(order->left_child());//goes to left child first
        ss<<order->contents()<<" ";//stores the contents
        ss<<InOrder(order->right_child());//then goes to right child
    }
    return ss.str();//returns the string
}
Beispiel #25
0
void InOrder(bitree_t *root)
{
	if (NULL == root) return;
	
	InOrder(root->lchild);
	
	printf("%c ", root->data);
	
	InOrder(root->rchild);

	return;
}
Beispiel #26
0
 int InOrder(TreeNode* root,int &k)
 {
     if(root)
     {
         int r1 = InOrder(root->left,k);
         k--;
         if(k==0)
             return root->val;
         int r2 = InOrder(root->right,k);
         return r1+r2;
     }
     return 0;
 }
Beispiel #27
0
void InOrder(HANDLE *h) {
  HANDLE *l, *r;
  if ((h != NIL)) {
    size_t index = h - node_arr;
    l = left_arr[index];
    r = right_arr[index];
    InOrder(l);
    static unsigned char counter = 0;
    if (counter++ == 0)   /* reduce IO */
      printf("%d @ 0x%x\n",value_arr[index], 0);
    InOrder(r);
  }
}
Beispiel #28
0
//  used to create the vertex using the nodes from the BST
void InOrder(TreeNodePtr treePtr, Graph G)  {
	// if tree is not empty, traverse
	if (treePtr != NULL) {
		InOrder(treePtr->leftPtr, G);
		j++;
		order++;
		G->vertex[j] = newGVertex("");
		strcpy(G->vertex[j].id, treePtr->data);
		treePtr->num = order; // gives the words a number
		InOrder(treePtr->rightPtr, G);

	}

}
Beispiel #29
0
void InOrder(AVL* root)
{
	if(root)
	{
		InOrder(root->lchild);
		printf("key: %d height: %d ", root->key, root->height);
		if(root->lchild)
			printf("left child: %d ", root->lchild->key);
		if(root->rchild)
			printf("right child: %d ", root->rchild->key);
		printf("\n");
		InOrder(root->rchild);
	}
}
Beispiel #30
0
/**
 * creates a string of the data in all nodes in the tree, in ascending order
 * separate by spaces (there should be a space after the last output value)
 */
string BSTree::InOrder(BSTNode* root)
{
    stringstream ordered;
    if (root == NULL)
    {
        ordered << "";
    }
    else 
    {
        ordered<<InOrder(root->left_child());
        ordered << root->contents() << " ";
        ordered<<InOrder(root->right_child());
    }
    return ordered.str();
}