19.09.2015 Views

Prentice.Hall.Introduction.to.Java.Programming,.Brief.Version.9th.(2014).[sharethefiles.com]

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

parent<br />

y<br />

y1 y u<br />

y1<br />

parent<br />

childOfu<br />

childOfu<br />

(a)<br />

(b)<br />

Figure 48.21<br />

Case 1 corresponds <strong>to</strong> a transfer operation in the corresponding 2-4<br />

tree.<br />

***END of NOTE<br />

<br />

<br />

Case 2: The sibling y of childOfu is black and its children are black or<br />

null. In this case, change y’s color <strong>to</strong> red. If parent is red, change it<br />

<strong>to</strong> black, and we are done, as shown in Figure 48.22. If parent is black,<br />

we denote parent double black, as shown in Figure 48.23. The doubleblack<br />

problem propagates <strong>to</strong> the parent node.<br />

y<br />

parent<br />

childOfu is<br />

double black<br />

y<br />

parent<br />

childOfu<br />

y1<br />

y2<br />

y1<br />

y2<br />

(a)<br />

(b)<br />

Figure 48.22<br />

Case 2: Recoloring eliminates the double-black problem if parent is red.<br />

y<br />

parent<br />

childOfu is<br />

double black<br />

y<br />

parent<br />

childOfu<br />

y1<br />

y2<br />

y1<br />

y2<br />

(a)<br />

(b)<br />

Figure 48.23<br />

Case 2: Recoloring propagates the double-black problem if parent is<br />

black.<br />

Note<br />

15

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

Saved successfully!

Ooh no, something went wrong!