10.07.2015 Views

2-3-4 Trees and Red/Black Trees

2-3-4 Trees and Red/Black Trees

2-3-4 Trees and Red/Black Trees

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

2-3-4 Insertion Algorithm‣ Key: Split 4 nodes on the way down‣ To insert a value,– 1. If node is a 4-node• Split the 3 values into a left 2-node, a right 2-node, <strong>and</strong> promote the middleelement to the parent of the node (which definitely has room) attaching childrenappropriately• Continue on to next node in search order– 2a. If node is a leaf, insert the value– 2b. Else continue on to the next node in search tree order‣ Insert 60, 20, 10, 30, 25, 50, 80Key: 4-nodes getsplit as you walkdown thus, a parentwill always haveroom for a valueAdd 8020 308020 3010 25 50 6010 25 50 60 80© Copyright 2013 Brent Nash & Mark <strong>Red</strong>ekopp, All Rights Reserved7

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!