HI, I am supposed to use a pre order transversal to search for an inputted value. The function returns a pointer to the node it is found in. If it is not found it should return NULL (I think). My code works fine if you only travel left. If the number is to the right at all or not in the tree, I get a segmentation fault. I can't figure out why it is doing this. Been working on it all day. Thank you in advance for any help!
Code:/********************************************************************/ /* SearchTree /********************************************************************/ /* * Input: The value being searched for, and the pointer to the root (intially) * Output: A pointer to the node where the value is found * Task: Uses a preorder transveral to search for the inputted value */ NodePtr SearchTree(int value, Tree T) { if(T != NULL) { if(T->value == value) return T; return SearchTree(value,T->Left); return SearchTree(value,T->Right); } else { return T; } }