Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Take the height-balanced tree code, and replace the key field by a field int leaves That field should contain the number of leaves below the

image text in transcribed

Take the height-balanced tree code, and replace the key field by a field int leaves That field should contain the number of leaves below the node, so n->leaves - 1 if n is a leaf, and n->leaves -n->left->leaves + n->right->leaves else. The leaves field must be updated after an insertion or deletion for all nodes on the path from the root to the changed leaf, and after a rotation for the changed nodes. Then you (1) replace the find function by object.t *find.by_number (tree node-t *tree, int k); which returns the object stored in the k-th leaf from left (start counting with the leftmost leaf as 1); (2) replace the insert function by void insert.by-number (tree.node.t *tree, int k, object.t *new-obj); which inserts new.obj in a new k-th leaf, moving all leaves above it one step to the right (without renumbering), and (3) replace the delete function by object.t * delete.by number (tree node.t *tree, int k); which deletes (and returns) the object stored in the k-th leaf, moving all leaves above it one step to the left (without renumbering). Take the height-balanced tree code, and replace the key field by a field int leaves That field should contain the number of leaves below the node, so n->leaves - 1 if n is a leaf, and n->leaves -n->left->leaves + n->right->leaves else. The leaves field must be updated after an insertion or deletion for all nodes on the path from the root to the changed leaf, and after a rotation for the changed nodes. Then you (1) replace the find function by object.t *find.by_number (tree node-t *tree, int k); which returns the object stored in the k-th leaf from left (start counting with the leftmost leaf as 1); (2) replace the insert function by void insert.by-number (tree.node.t *tree, int k, object.t *new-obj); which inserts new.obj in a new k-th leaf, moving all leaves above it one step to the right (without renumbering), and (3) replace the delete function by object.t * delete.by number (tree node.t *tree, int k); which deletes (and returns) the object stored in the k-th leaf, moving all leaves above it one step to the left (without renumbering)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

How Do I Use A Database Research Tools You Can Use

Authors: Laura La Bella

1st Edition

1622753763, 978-1622753765

More Books

Students also viewed these Databases questions