March 2019
Intermediate to advanced
336 pages
9h 9m
English
The PostOrderTraverseTree method traverses the nodes in a post order (left, right, current node). In the following code snippet, the PostOrderTraverseTree method of the BinarySearchTree class visits all nodes with post-order traversing. The function method is passed as a parameter to the method. The tree.lock instance is locked first and the Unlock method is deferred on the tree lock instance before calling the postOrderTraverseTree method:
// PostOrderTraverseTree methodfunc (tree *BinarySearchTree) PostOrderTraverseTree(function func(int)) { tree.lock.Lock() defer tree.lock.Unlock() postOrderTraverseTree(tree.rootNode, function)}
Read now
Unlock full access