Function to traverse a binary tree
问题 I'm just starting with trees and am writing a function that traverses a binary tree and visits every node. I'm calling a function called doSomething(TreeNode *thisNode) for each node in the tree. I want to make sure if what I have is correct and that I'm on the right track? Thanks! void MyTree::Traverse(TreeNode *rt) { If(rt != NULL) Traverse(rt -> left); doSomething (rt); Traverse(rt -> right); } 回答1: Almost, but not quite. The if statement in C++ is not capitalized, and you must add