Welcome to the new platform of Programmers Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use it's exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
code needed for this new data structure
Want to build a C++ Template code for the following modified Binary tree structure:
each node has left, right and parent pointer.
each node has a number of values in sorted order.
If a node has to null child pointer call it a leaf node and if it has one null child pointer call it a half leaf.
Search for the bounding node. ie min val<data<max val
If a node is found, then check for room for another entry. If the
insert value will tit, then insert it into this node and stop.
Else remove the minimum element from the node, insert the original
insert value, and make the minimum element the new insert
value. Proceed from here directly to the leaf containing the
greatest lower bound for the node holding the original insert
value. The minimum element (the new insert value) will be
inserted into this leaf, becoming the new greatest lower bound
value for the node holding the insert value.
If the search exhausts the tree and no node bounds the insert
value, then insert the value into the last node on the search path
(which is a leaf or a half-leaf). If the insert value fits. then it
becomes the new minimum or maximum value for the node.
Otherwise, create a new leaf (so the insert value becomes the
first element in the new leaf).
If a new leaf was added, then check the tree for balance by following
the path from the leaf to the root. For each node in the
search path (going from leaf to root), if the two subtrees of a
node differ in depth by more than one level, then a rotation
must be performed Once one rotation has been done, the tree is rebalanced and processing stops.