Practice 30 C Programming Questions on Tree
Q1. Define a structure for a node in a binary tree.
Q2. Create a binary tree with a root node and two children.
Q3. Write a program to perform an inorder traversal of a binary tree.
Q4. Write a program to perform a preorder traversal of a binary tree.
Q5. Write a program to perform a postorder traversal of a binary tree.
Q6. Write a program to calculate the height of a binary tree.
Q7. Write a program to count the total number of nodes in a binary tree.
Q8. Write a program to count the number of leaf nodes in a binary tree.
Q9. Write a program to check if a binary tree is a full binary tree (every node has 0 or 2 children).
Q10. Write a program to find the maximum element in a binary tree.
Q11. Write a program to find the minimum element in a binary tree.
Q12. Write a program to calculate the sum of all nodes in a binary tree.
Q13. Write a program to check if two binary trees are identical.
Q14. Write a program to count the number of internal nodes (non-leaf nodes) in a binary tree.
Q15. Write a program to check if a binary tree is height-balanced.
Q16. Write a program to calculate the depth of a node in a binary tree.
Q17. Write a program to print the ancestors of a given node in a binary tree.
Q18. Write a program to find the lowest common ancestor (LCA) of two nodes in a binary tree.
Q19. Write a program to check if a binary tree is a binary search tree (BST).
Q20. Write a program to convert a binary tree into a doubly linked list in in-order traversal.
Q21. Write a program to find the height of a specific node in a binary tree.
Q22. Write a program to convert a binary tree into its mirror image.
Q23. Write a program to print all leaf nodes of a binary tree.
Q24. Write a program to count the number of nodes in a full binary tree given the height.
Q25. Write a program to find the diameter (longest path) of a binary tree.
Q26. Write a program to calculate the sum of all nodes in a binary tree.
Q27. Write a program to calculate and print the average value of nodes at each level of a binary tree.
Q28. Write a program to find the minimum depth of a binary tree.
Q29. Write a program to print the boundary nodes of a binary tree in anti-clockwise order.
Q30. Write a program to find and print all paths from the root to leaf nodes in a binary tree.
Bikki Singh
Hi, I am the instructor of TechnoVlogs. I have a strong love for programming and enjoy teaching through practical examples. I made this site to help people improve their coding skills by solving real-world problems. With years of experience, my goal is to make learning programming easy and fun for everyone. Let's learn and grow together!