Question: The height of a binary tree is defined to be 0 for an empty tree, 1 for a tree consisting of a single node, 2

The height of a binary tree is defined to be 0 for an empty tree, 1 for a tree consisting of a single node, 2 for a tree consisting of a root node with one or two children that are leaf nodes, etc.

Complete the definition of function height() below so it returns the height of the tree whose root is given as its argument. (Hint: recursion is your friend.)

// return the height of the binary search tree with node* head_ptr

int height(node* head_ptr)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!