Thread: print a binary tree!

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Aug 2001
    Posts
    2

    Cool print a binary tree!

    hi!!
    I am looking for a way to print a binary tree as a binary tree,with a root and nodes.so when you look at the screen you will see a binary tree not some data in line!
    thanks !!!!
    i am looking forward for an answer!

    FOR mixOmatt!one way is as shown below,but the fuction has a logic bug!and the results are not printed as i expected!!

    void viewtree(struct node *t,int x,int y)
    {
    if(t==NULL)return;
    gotoxy(x,y);
    printf("%d",t->key);
    viewtree(t->left,x-4,y+1);
    viewtree(t->right,x+4,y+1);
    }

    i am waiting for your reply!
    you dig?
    Last edited by basilis; 08-26-2001 at 04:16 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Binary Tree Search
    By C++Newbie in forum C++ Programming
    Replies: 7
    Last Post: 04-05-2011, 01:17 AM
  2. Binary Tree
    By Ideswa in forum C Programming
    Replies: 12
    Last Post: 10-25-2007, 12:24 PM
  3. Search Engine - Binary Search Tree
    By Gecko2099 in forum C Programming
    Replies: 9
    Last Post: 04-17-2005, 02:56 PM
  4. searching and insertion in a binary search tree
    By galmca in forum C Programming
    Replies: 1
    Last Post: 03-26-2005, 05:15 PM
  5. print a binary tree!
    By basilis in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 08-26-2001, 07:40 AM