CS 310 Unit 13 Red Black Trees

CS 310 Unit 13 Red Black Trees - Exam 2 Wednesday, March...

Info iconThis preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon
Exam 2 Wednesday, March 26, 2008 Units 9-14
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CS 310 Unit 13 Red Black Trees Furman Haddix Ph.D. Assistant Professor Minnesota State University,  Mankato Spring 2008
Background image of page 2
Red Black Trees Objectives Coloring for synchronization and  coordination Coloring in Red Black Trees Red Black Tree Specification Red Black Tree Examples and Algorithms Insertion Deletion Text, Chapter 13
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Balancing Red Black Search Trees Principal general technique is rotation as used in AVL  trees Left rotation   moves object node to the left so that  its right child becomes its parent Right rotation   moves object node to the right so  that its left child becomes its parent Rotation exchanges the roles of a parent and child  without changing the order of the nodes In red-black trees, a specialized techique, recoloring, is  also used.  Node recoloring is used, sometimes in combination  with rotation, to fix red-black trees following insertion  or deletion. Although rotation maintains the order of nodes within  the search tree, it does not necessarily maintain the  red-black (bichromatic) characteristic.
Background image of page 4
Rotation in Red Black Trees Overview  Rotation moves the rotation object node x with its child y. In left-rotate(), the child y was x’s right child x becomes y’s left child y’s left subtree becomes x’s right subtree In right-rotate(), the child y was x’s left child x becomes y’s right child y’s right subtree becomes x’s left subtree left-rotate() and right-rotate() are used with both insert()  and delete() to restore the red-black conditions In both insert() and delete(), all color concerns are dealt  with in the …Fix() layer
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Red-Black Tree Rotation Example x refers to the root of the  subtree in which the rotation  will take place y is the child of x   left child  for a right-rotate() right-rotate() In right-rotate(), the child y  starts as x’s left child x becomes y’s right child y’s right subtree becomes  x’s left subtree Note that bh level changes –  this must be dealt with in the  …fix() routine, external to the  rotation routines E F 5 B 8 x 7 2 1 y
Background image of page 6
Coloring for Coordination In computer science coloring, usually refers to  state variables used to synchronize or  coordinate between different elements of an  application Example: Using tree coloring as a means of determining if all  nodes in the tree have reached the same state, have  the same version of information, etc.
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 48

CS 310 Unit 13 Red Black Trees - Exam 2 Wednesday, March...

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online