Hi all,
I have a function signature: vector<int> tree_highest_path (Node *root);
which gets a pointer to a binary-tree root.(the struct is:[int id, Node *right, Node left].
I need to return a vector of id's of the highest path of the tree.
can you help me with that? example:
root:6, left of root:5, right of root:3, right of right:1
will return this vector: 6->3->1.
Hi,
I can't understand your code.
What is this path in 1st line?
Where is the vector variable? (look at the function signature)
What are those left and right variables? You didnt define them. Same as longest.
What is path function?
What is length() function? vector doesnt support length() operation.
What is push() function?
p.s - this function should be written in C++ in case I haven't said it
> What is this path in 1st line?
a proper structure that would store the ids of the nodes, and support operations like adding an id and obtain the length.
> What are those left and right variables? You didnt define them. Same as longest.
They are paths
It can be deduced as they are assigned the result of the `longest_path...()' function
> What is path function?
Construct a path with only one id. If you prefer