>Did you compile it and get it to work?
Yes. And a cursory look at the algorithm shows nothing untoward. Show me how you're calling these functions. It could be that there's nothing wrong with your tree, but your driver is using it incorrectly.