Download as pdf or txt
Download as pdf or txt
You are on page 1of 9

SEARCHT-REESZ-3T-RF.

ES
:
Multi
way search Tree
liuwdayseaoch Tree)

Degree 3 ( 2 -
3 trees are Multi
way search Trees with
degree 3)
search Trees )
Bp
( These Balanced
height

ees are

i :÷÷:÷:

Cannot have
±¥÷÷÷÷÷÷÷ .

duplicates

CREATlONOF2-3TRE

KEYS : 20 , 30 ,
40
,
50
,
60 ,
10
,
15 ,
70
, 80 ,
90

20
,
30 ¥7

no l "

⇐iT

¥F¥±
""

÷i÷IEi¥ ¥F¥
10,15

Eii¥ ,
7980,90

Eii¥¥ :
Eia

DELETINGT.RO#-3TREE

sgironpiy
cas : Delete

Fit
and merge
Dgeolete
ca :

"

Ei -1¥,

⇐T¥i¥T
Efi
FIT ¥T¥
n÷gsi
'

¥4 17¥ Merging,iw
right

CA3
P%80W
:

⇐ii÷¥⇐¥÷ i¥i¥E÷¥ .
ANAL

/!
Tree with min nodes

for given height

Y
Minimum
I
n - - -

7. ology!g !
man -
'

Il
t \ .

¥¥¥¥F¥¥¥I¥
Man n = It 3 t 32 . . . . .

'
3h
'
= - ,

Ti

Min h =
log, [ n 13 -
I ) ti ) -
I

0 ( login )

Minimum as well as manimum


height is
logn

Tees:*:S ::c:: e
::: : awe
REDBLACkTRE


It is a
height balanced Binary search Tree ,
similar to 2-3-4 tree .

Every node is either Red or Black .


Root of a Tree is Black .


NULL is also Black ④
/ I
.


Number of Blacks on
paths from Root to leaf are same .


No 2 consecutive Red ,
Parent and children of red are Black . ⑤ ④


"

New inserted Node is Red .
/ ¥
I

Height in
login Eh E 2.
login -1 w•.④Hea Ea Ea

Eal
*

CREATIONOFREDBLACKTREEU
ncleisred ( for Node ) UnueisBl

O Zig ( LLIRR) ( RLILR)


Zig Zig-Zag
-

& ⑦ Parent
- -

Eam Em -6 # Node
① F-
£
§ ↳

Era
p

p I

690 BON
' N

,
ON A
① ④ ① ④
RE COLOURING

ROTATION

8
KELLS : 10 ,
20 ,
30
,
50
,
40 ,
GO ,
70 , 80
,
4
,

INSECT

to ④

%
20
30 ④

too ④ ④
too
50

④ ④ ④ ④
' '
④ soo
Root must be black

40 ⑥ ⑥
✓ la Il
④ "
④ ④ ④
tea / )
& p

E
60

④ ④ ④ ④
' ' ' '
⑤ ⑤
'
④ too
70

④ ④ ④ ④
' ' ' '
⑤ ⑤ ④
too / \
Xo ④

Do
t '
2 .

80 ④ ④
^ it
④ ④ ④ ④
' ' ' '
④ ⑤
9h
④ ④ ④

I do
3 .


It
⑥ ④
' ' ' '
④ ④ ④

do
u ④
It
⑥ ④
' ' ' '
④ ④ ④

& do
8 ④ ④
^ it
④ ④ ⑥ ④
11 11 11 It
④ ⑤ ④ ⑧ ⑤ ④

6 too 66 do

red 1 black
height only log
=
n

height red and black =


2
login
2-3-4TREESVSR.fr#ACKTREES


- - it
# ④ ④

7¥ ④
- I - ri


- -- ri
II

④ ⑤ ④

REDBLACKTREEDELETIONCASES.rs#E1
: Deleted Node is Red Node

Befooebeletion Afterbeletion
delete
Simply as it

C) C) is a leaf node and


/ L l red
O O O

o o
' i r '
O O O O
* £
§
C) Simply delete because
✓ I if red node is deleted ,

O O O ① the
path of black nodes

¢ remains
unchanged
Node is black and is red
cast sibling
:

Befooebeletion Afterbeletion

① C) Perform rotation

l l l
o
q o

CALEB Node black and also black


: is
sibling is

Befooebeletion Afterbeletion

C) C) Change sibling to
✓ \ I red and parent
O ⑤ ⑤ to black
/ y / I
.

×
Recolor
O O O O

o o Perform rotation


1×0
§
✓ §
0

You might also like