March 2019
Intermediate to advanced
336 pages
9h 9m
English
Mutable TreeSets can use add, update, and delete operations on the tree and its nodes. insertTreeNode updates the tree by taking the rootNode and treeNode parameters to be updated. The following code snippet shows how to insert a TreeNode with a given rootNode and TreeNode:
// insertTreeNode methodfunc insertTreeNode(rootNode *TreeNode, newTreeNode *TreeNode) { if newTreeNode.key < rootNode.key { if rootNode.leftNode == nil { rootNode.leftNode = newTreeNode } else { insertTreeNode(rootNode.leftNode, newTreeNode) } } else { if rootNode.rightNode == nil { rootNode.rightNode = newTreeNode } else { insertTreeNode(rootNode.rightNode, newTreeNode) } }}
Let's discuss the different mutable TreeSets in the following sections.
Read now
Unlock full access