Question 5. Trees [9]

Below are definitions for tree nodes and two functions that operate on them. Provide implementations for the two functions.

// each node in the tree has pointers to its parent
//    node in addition to its two chilren
struct tnode {
   int data;
   tnode *parent, *left, *right;
};

// given a pointer to a node in the tree,
// return a pointer to the root node
tnode *findRoot(tnode *n);

// given pointers to two nodes, return true 
// if they are non-null and in the same tree,
// false otherwise
bool sameTree(tnode *n1, tnode*n2);