Write a C program to create a copy of a tree
October 28, 2007 · Filed Under Placement Questions, Tree
![]() Don't want to miss a single bit? Subscribe By Email for Daily Jobs |
Here is a C program which does that…
mynode *copy(mynode *root)
{
mynode *temp;
if(root==NULL)return(NULL);
temp = (mynode *) malloc(sizeof(mynode));
temp->value = root->value;
temp->left = copy(root->left);
temp->right = copy(root->right);
return(temp);
}
Related Articles
- Write a C program to create a mirror copy of a tree (left nodes become right and right nodes become left)!
- Write C code to return a pointer to the nth node of an inorder traversal of a BST.
- Write C code for iterative preorder, inorder and postorder tree traversals
- How do you reverse a singly linked list? How do you reverse a doubly linked list? Write a C program to do the same.
- How do you reverse a singly linked list? How do you reverse a doubly linked list? Write a C program to do the same.


