Need help with C++, binary tree node, recursive linear-time function!! Thank you
ID: 3692865 • Letter: N
Question
Need help with C++, binary tree node, recursive linear-time function!! Thank you!!
--------------------------------------------------------------------------------------
Suppose that a node in a binary tree is represented as follows:
struct Node {
int key;
struct Node *left, *right; // pointers to the left and right children
};
Complete the code of a recursive function findPath below that takes a pointer to the root of a
binary tree and returns a vector of keys on a path (any path) from the root to the node with a
given key value. This function has the following arguments:
root is a pointer to an instance of struct Node that corresponds to the root of a tree
path is a reference to a vector of node keys
key is the key of the node to which a path needs to be found
// find a path from root node to a given node and store the found path in a vector path
// return true if a path exists otherwise false
bool findPath(Node *root, std::vector &path, int k)
{
}
--------------------------------------------------------------------------------------
Plus I gave the links to my other 4 problems if you want to do those as well! Thank you!
https://www.chegg.com/homework-help/questions-and-answers/need-help-c-binary-tree-node-recursive-linear-time-function-thank-plus-gave-links-4-proble-q12397569
https://www.chegg.com/homework-help/questions-and-answers/need-help-c-binary-tree-node-recursive-linear-time-function-thank-suppose-node-binary-tree-q12397737
https://www.chegg.com/homework-help/questions-and-answers/need-help-c-binary-tree-node-recursive-linear-time-function-thank-suppose-node-binary-tree-q12397779
https://www.chegg.com/homework-help/questions-and-answers/need-help-c-binary-tree-node-recursive-linear-time-function-thank-suppose-node-binary-tree-q12397829