Topic 5: Implementation of Functions to Binary Trees
Consider the following definition of a binary tree structure:
typedef struct BTnode * node;
struct BTnode {
int key;
node left;
node right;
};
5.a: Calculation of a Binary Tree
Write a function in C programming language that can find and return the height of a Binary Tree.
Reminder: The height of a binary tree is the length of the longest path from the root of the binary tree to a leaf.
5.b: Calculating the Cost of the more expensive a Binary Path Tree
Write a function in C programming language that can find and return the cost of more expensive path from the root of a binary tree to a leaf.
Reminder: The cost of a path in a binary tree it is equal to the sum of the nodes in Binary Tree belonging to this path.
5.c: Balanced Binary Trees
Write a function in C programming language which would be able to find whether a particular Binary Tree is balanced.
Reminder: Balanced Binary Tree is a binary tree whose depth of any two leaves differ by at most 1.