Question: EX 1 Write a BST function named common _ ancestors that takes two values of templated type T as arguments: DLList common _ ancestors (

EX1 Write a BST function named common_ancestors that takes two values of templated type T as arguments:
DLList common_ancestors(const T & val1, const T & val2) const
The function should search the BST for these values and return a Doubly Linked List (DLList) containing the values of the common ancestors of val1 and val2.
Here's what the function should do in details:
If both val1 and val2 are found in the BST:
The function should return a DLList containing all the nodes that are ancestors of both val1 and val2.
If either val1 or val2 is not found in the BST:
The function should return an empty DLList The function should assume the BST has unique values for each node (no duplicate values).
Note. You are not allowed to declare any additional data members, but you can define helper functions in the private section of the BST class. use only include string, do NOT use vector or any other STL

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!