Question: Write a C++ definition of a function called negatives that takes a binary tree T and returns a tree that has the same tree
Write a C++ definition of a function called negatives that takes a binary tree T and returns a tree that has the same tree structure as tree T, but whose nodes contain the negatives of corresponding nodes in T. For example, if the root of T contains 3, then the root of negatives (7) contains -3. If the root of T contains -4, then the root of negatives(T) contains 4. (If T is empty, negatives(T) is also empty.) Function negatives must not modify T. It must produce the result tree using newly allocated nodes. Do not assume that any tree functions are predefined for you. A heading is given. Node* negatives (const Node* T)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
