March 2019
Intermediate to advanced
336 pages
9h 9m
English
The inOrderTraverseTree method traverses from the left of the tree to root of the node and then to the right of the tree. The inOrderTraverseTree method takes treeNode and function as parameters. The method recursively calls the inOrderTraverseTree method with function and then leftNode and rightNode in separate calls. The function method is invoked with the value of treeNode:
// inOrderTraverseTree methodfunc inOrderTraverseTree(treeNode *TreeNode, function func(int)) { if treeNode != nil { inOrderTraverseTree(treeNode.leftNode, function) function(treeNode.value) inOrderTraverseTree(treeNode.rightNode, function) }}
Read now
Unlock full access