algorithm insert(value prevalue has passed custom type checks for type postvalue has been placed in the correct location in the tree if root root node(value else insertnode(rootvalue end if end insert algorithm insertnode(currentvalue precurrent is the node to start from postvalue has been placed in the correct location in the tree while preserving tree balance if value current value if current left current left node(value else insertnode(current leftvalue end if else if current right current right node(value else insertnode(current rightvalue end if end if checkbalance(current end insertnode deletion our balancing algorithm is like the one presented for our bst (defined in ss the major difference is that we have to ensure that the tree still adheres to the avl balance property after the removal of the node if the tree doesn' need to be rebalanced and the value we are removing is contained within the tree then no further step are required howeverwhen the value is in the tree and its removal upsets the avl balance property then we must perform the correct rotation(