I have a structure of tree that looks like this. Without changing the structure of tree, I am required to write a function that return's the depth of a node given it's id. (id is a unique number that represents the node). i.e. something like int getDepth(CPPtr tree,int id).Code://Declare Data Structure struct CP { int id; //ID of the Node int data; //Data of the Node CP * left; //Pointer to the Left Subtree CP * right; //Pointer to the Right Subtree }; typedef CP * CPPtr;
Can anyone help me? Your help would be much appreciated.



LinkBack URL
About LinkBacks



