9780132122306, Chapter 13, Problem 6E

png

School

Arizona State University *

*We aren’t endorsed by this school

Course

142

Subject

Computer Science

Date

Nov 24, 2024

Type

png

Pages

1

Uploaded by CountCoyoteMaster507

Report
Chapter 13, Problem 6E Problem Draw the 2-3-4 tree that results from inserting p, ¢, m, j, v, f, and b, in the order given, inio a 2-3-4 tree that contains a single node whose value is n. Step-by-step solution Step 1075 2-3-4 tree A 2-3-4 tree is a tree that can have 2 nodes, 3 nodes and 4 nodes i.e. each non-leaf node has either two or three or four children and all the leaf nodes are at the same level. + A 2-node is a node that has one data element and two children. « A 3-node is a node that has two data elements and three children. « A 4-node is a node that has three data elements and four children. Constructing a 2-3-4 tree « Initially the 2- tree has single node n «Insertp Since p is greater than n, insert p in the node after n «Insertc Since c is greater than p and n, insert ¢ in the node before p Step2075 +Insertm The element m has to be inserted before n in the node . Since the node is a 4-node and can contain only three elements, split this 4-node by moving the middle value up. Since it is the root, create a new root and move n into it as shown. Now insert m in the node as shown. Step3 075 ~Insertj The element j is to be inserted in the node , before m and after c, ie as middle element as shown. «Insertv The element v is to be inserted in the node after p, as shown. Step4 i 5 Insert f The element f has to be inserted in the node . Since the node is a 4-node and can contain only three elements, split this 4-node by moving the middle value j up, into the root node as shown. O @ @ Now insert f in the node after ¢ as shown Step 5075 «Insertb The element b is inserted in the node before ¢ as shown. © 4 The final 2-3-4 tree after inserting p, ¢, m, j, v, f, and b, into a 2-3-4 tree that initially contains a single node n is as shown below. @ @V
Discover more documents: Sign up today!
Unlock a world of knowledge! Explore tailored content for a richer learning experience. Here's what you'll get:
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help