URI:
   DIR Return Create A Forum - Home
       ---------------------------------------------------------
       techsuns
  HTML https://techsuns.createaforum.com
       ---------------------------------------------------------
       *****************************************************
   DIR Return to: Trees
       *****************************************************
       #Post#: 53--------------------------------------------------
       build tree
       By: dinesh Date: August 24, 2012, 1:43 am
       ---------------------------------------------------------
       This is a very basic problem with a little pointer manipulation.
       Write code that builds the following little 1-2-3 binary search
       tree...
       2
       / \
       1   3
       Write the code in three different ways...
       a: by calling newNode() three times, and using three pointer
       variables
       b: by calling newNode() three times, and using only one
       pointer variable
       c: by calling insert() three times passing it the root
       pointer to build up the tree
       #Post#: 73--------------------------------------------------
       Re: build tree
       By: dinesh Date: September 6, 2012, 2:57 am
       ---------------------------------------------------------
       // call newNode() three times
       struct node* build123a() {
       struct node* root = newNode(2);
       struct node* lChild = newNode(1);
       struct node* rChild = newNode(3);
       root->left = lChild;
       root->right= rChild;
       return(root);
       }
       // call newNode() three times, and use only one local variable
       struct node* build123b() {
       struct node* root = newNode(2);
       root->left = newNode(1);
       root->right = newNode(3);
       return(root);
       }
       
       /*
       Build 123 by calling insert() three times.
       Note that the '2' must be inserted first.
       */
       struct node* build123c() {
       struct node* root = NULL;
       root = insert(root, 2);
       root = insert(root, 1);
       root = insert(root, 3);
       return(root);
       }
       #Post#: 76--------------------------------------------------
       Re: build tree
       By: kranthipls Date: September 6, 2012, 4:13 am
       ---------------------------------------------------------
       Good One ::)
       *****************************************************