











Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
The concepts of balanced trees and heaps, specifically multiway search trees and 2-3 trees, and the algorithm heapsort. Multiway search trees are search trees that allow more than one key in the same node, with properties such as fan-out and height. 2-3 trees are a type of multiway search tree that may have 2-nodes and 3-nodes, and are height-balanced. Heaps are binary trees with keys at their nodes, essentially complete, and the key at each node is greater than or equal to keys at its children. Heapsort is an efficient sorting algorithm that uses a heap to find the maximum element and place it at the correct position in the sorted array.
Typology: Study notes
1 / 19
This page cannot be seen from the preview
Don't miss anything!
Oct
A
multiway search
tree
is
a
search
tree
that
allows
more
than
one
key
in
the
same
node
of
the
tree.
An
n
ā
node
contains
n
ā^1
ordered
keys
A
n
ānode
divides
the
key
range
into
n
intervals
(Ranges
for
the
nodeās
n
subtrees)
k
1
<
k
2
<
k
3
[ k
, 1 k
2
)
< k
1
ā„
k
n-
1
a 3-node
Definition
A
^2
ā^3
tree
is
a
search
tree
that
may
have
2
ānodes
and
3
ā
nodes
is
height
ābalanced
(all
leaves
are
on
the
same
level)
K
K
,
K 1
2
( K
,
K
)
1
2
2-
node
3-
node
<
K
> K
<
K
K
1
2
New
keys
are
always
inserted
into
a
leaf
of
the
tree.
If
the
leaf
is
a
3
ānode,
itās
split
into
two
with
the
middle
key
promoted
to
the
parent.
This
may
cause
splits
to
propagate
up
the
tree.
K
K
,
K 1
2
( K
,
K
)
1
2
2-
node
3-
node
<
K
> K
<
K
K
1
2
log
3
n
h
log
2
n
Search,
insertion,
and
deletion
are
in
(log
n
The
idea
of
tree
can
be
generalized
by
allowing
more
keys
per
node
2
ā^3
ā^4
trees
B
ātrees
10
5
4
2
7
1
10
5
2
7
1
10
5
6
2
7
1
a heap^ a heap
not a heapnot a heap
not a heapnot a heap
Note: HeapāNote: Heap
ās elements are ordered top down (along any paths elements are ordered top down (along any path down from its root), but they are not ordered leftdown from its root), but they are not ordered left to right
to right
There
exists
a
unique
binary
tree
with
n
nodes
that
is
essentially
complete,
with
h
log
2
n
The
root
contains
the
largest
key
The
subtree rooted
at
any
node
of
a
heap
is
also
a
heap
heap
can
be
represented
as
an
array
Step
0:
Initialize
the
structure
with
keys
in
the
order
given
Step
1:
Starting
with
the
last
(rightmost)
parental
node,
fix
the
heap
rooted
at
it,
if
it
doesnāt
satisfy
the
heap
condition:
keep
exchanging
it
with
its
largest
child
until
the
heap
condition
holds
Step
2:
Repeat
Step
1
for
the
preceding
parental
node
7
2
9
6
5
8
2
9
6
5
8
7
2
9
6
5
8
7
2
9
6
5
8
7
9
2
6
5
8
7
9
6
2
5
8
7
Construct a heap for the list 2, 9, 7, 6, 5, 8
Stage
Construct
a
heap
for
a
given
list
of
n
keys
Stage
Repeat
operation
of
root
removal
n
times:
Exchange
keys
in
the
root
and
in
the
last
(rightmost)
leaf
Decrease
heap
size
by
1
If
necessary,
swap
new
root
with
larger
child
until
the
heap
condition
holds
Exchange
rootās
key
with
last
key
in
heap.
Decrease
heap
size
by
Heapify the
smaller
tree
by
sifting
new
root
down
in
same
manner
as
bottom
up
construction
Step
of
heapsort repeats
this
until
heap
is
empty.
)) 1
(
log
( 2
(^2) )
( 2
2
(^10)
ā
=
ā
ā =
n
n
i
h
h i
i
Stage
1:
Build
heap
for
a
given
list
of
n
keys
worst
ācase: C (
n
)^
=
C(n)
Ń
O(n)
Stage
2:
Repeat
operation
of
root
removal
n
ā^1
times
(fix
heap)
worst
ācase: C (
n
)^
=
C(n)
Ń
O(n log
n)
Both
worst
ācase
and
average
ācase
efficiency:
Ī
( n
log
n
)
In
āplace:
yes
Stability:
no
(e.g.,
1
i
ā^1 =^1
2
log 2 n i
i