the following is a function which computes the double tree of a given tree. here is the description of a double tree.
doubleTree() For each node in a binary search tree, create a new duplicate node, and insert the duplicate as the left child of the original node. The resulting tree should still be a binary search tree. So the tree... 2 / \ 1 3 is changed to... 2 / \ 2 3 / / 1 3 / 1 *FUNC DEFN* struct node * doubletree(struct node *root){ if(root==NULL) return NULL; else{ struct node *temp=malloc(sizeof(struct node)); temp->data=root->data; temp->left=root->left; temp->right=NULL; root->left=temp; doubletree(temp->left); doubletree(root->right); return root; } } *FUNC CALL* tree=doubletree(tree); // tree is the root of some BST root is being returned cos the pointer passed to the function (root of the tree) is not modified. (call by value) However in between recursive calls, the modification made to the pointers (like temp->left and root->right) are being retained. Why is it so?? Please help. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.