March 2019
Intermediate to advanced
336 pages
9h 9m
English
The InsertNode method inserts a node into the AVL tree. This method takes treeNode, which is a double TreeNode pointer, and the key value as parameters:
// InsertNode methodfunc InsertNode(treeNode **TreeNode, key KeyValue) { *treeNode, _ = insertRNode(*treeNode, key)}
The example output of the InsertNode method is shown in the following screenshot. The InsertNode method calls the insertRNode method with the rootNode parameters and node to be inserted. rootNode has a key value of 5 and the node to be inserted has a key value of 6. The tree needs to be balanced.
Hence, the next call will be rootNode with key 8 and node to be inserted. The next step calls rootnode with key value 7 and node to be inserted. The last call ...
Read now
Unlock full access