March 2019
Intermediate to advanced
336 pages
9h 9m
English
In the following code, the searchNode method takes treeNode, a pointer of the TreeNode type, and a key integer value as parameters. The method returns true or false after checking whether treeNode with the same value as key exists:
// searchNode methodfunc searchNode(treeNode *TreeNode, key int) bool { if treeNode == nil { return false } if key < treeNode.key { return searchNode(treeNode.leftNode, key) } if key > treeNode.key { return searchNode(treeNode.rightNode, key) } return true}
Read now
Unlock full access