Question: 6-4 Lowest Common Ancestor (25point(s)) Programming language is c. Let us store a binary tree in an array (root at position 1). Assume that all

 6-4 Lowest Common Ancestor (25point(s)) Programming language is c. Let us

6-4 Lowest Common Ancestor (25point(s)) Programming language is c. Let us store a binary tree in an array (root at position 1). Assume that all the keys are positive, and 0 represents the NULL node. Please write a function to find the Lowest Common Ancestor of two nodes at positions P1 and P2. Format of function: int LCAC int [], int Pi, int P2 ); where T is the tree. The function is supposed to return the position index of the lowest common ancestor of the nodes at P1 and P2. If one of the nodes is NULL, you must print in a line ERROR: T[x] is NULL where x is the NULL position (if both P1 and P2 are NULL positions, then output P1), and return 0 as the signal of error. Sample program of judge: #include

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!