The document outlines the implementation of a Binary Tree in C, detailing the creation of a sample binary tree and providing skeleton code for the task. It specifies various operations to be implemented, including different types of traversals, height calculation, and node counting. Additionally, it includes bonus tasks such as printing the left view and checking if the tree is height balanced.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
3 views2 pages
Tree Practice
The document outlines the implementation of a Binary Tree in C, detailing the creation of a sample binary tree and providing skeleton code for the task. It specifies various operations to be implemented, including different types of traversals, height calculation, and node counting. Additionally, it includes bonus tasks such as printing the left view and checking if the tree is height balanced.
struct Node* root = createNode(1); root->left = createNode(2); root->right = createNode(3); root->left->left = createNode(4); root->left->right = createNode(5); root->right->right = createNode(6); return root; } Part 2: Implement the Following Functions
Write separate functions in C to implement the following operations:
1. Inorder Traversal (Left, Root, Right)
2. Preorder Traversal (Root, Left, Right) 3. Postorder Traversal (Left, Right, Root) 4. Level Order Traversal (Use Queue) 5. Calculate Height of the Tree 6. Count Total Number of Nodes 7. Count Number of Leaf Nodes 8. Count Number of Internal Nodes 9. Find Maximum Value in the Tree 10.Search for a Given Value in the Tree 11.Check if Two Trees are Identical 12.Mirror the Binary Tree
Bonus Tasks:
● Print the left view of the binary tree.
● Check if the binary tree is height balanced. ● Convert the binary tree into a doubly linked list (using in-order traversal)