Question: Consider the basic definition of a Binary Search Tree ( BST ) , where: a BST T is an object that has a single attribute:
Consider the basic definition of a Binary Search Tree BST where:
a BST is an object that has a single attribute: root which is a pointer to its root node.
each node of the tree has attributes:
key: identifier of the object stored in the node.
parent: pointer to the parent node; NIL for T root.
left: pointer to the left child; eventually NIL.
right: pointer to the right child; eventually NIL.
the keys of the nodes of left subtree of a node are all smaller the key of
the keys of the nodes of the right subtree of a node are greater or equal to the key of
Write a divide and conquer algorithm to compute and return the size of subtree rooted at a
given node of a BST The size of the subtree rooted at is the number of nodes in that
subtree, including For instance,
the size of the tree rooted at a leaf node is
the size of the subtree rooted at T root is the total number of nodes in the tree T
What is the running time of this algorithm? Explain.
Assume we want to augment the initial definition of the BST by an additional attribute size
per node that stores the size of the subtree rooted at it
Provide the modified AugmentedBSTinsert pseudocode of the insertion operation that
maintains this new attribute and has the same asymptotic running time as the original BST
insert ie where is the height of the tree.
Write the pseudocode of AugmentedBSTselect operation, which returns the key in a BST
tree with a given order statistic ie returns the smallest element of the tree. Augmented
select must have a running time.
If we want to achieve selection operation, we need the BST to be balanced eg AVL
So at insertion and deletion we need to eventually perform rotations to reestablish the tree
balance. The modified AugmentedBSTinsert should update the size attribute for the
nodes affected by the basic BST insertion; however the subsequent eventual rotations will
render it incorrect for a few. Provide a modified AugmentedLEFTROTATE pseudocode that
correctsfixes the size attributes disrupted by the rotation.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
