Revision as of 17:00, 27 April 2012 by Wang820 (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Shiyu Wang Lec28 April 27th

typedef struct treenode {

 struct treenode *left;
 struct treenode *right;
 int value;

}Node;

Node* root=NULL;

root=tree_insert(root,13);

root=tree_insert(root,7);

root=tree_insert(root,22);

Node*Tree_insert(Node*n,int v) {

 if(n==NULL)
 {
   return Node_construct(v);
 }
 if((n->value)==v)
 {
   return n;
 }
 if((n->value)>v)
 {
   n->left=Tree_insert(n->left,v);
 }
 else
 {
   n->right=Tree_insert(n->right,v);
 }
 return n;

}

Alumni Liaison

Questions/answers with a recent ECE grad

Ryne Rayburn