Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Datenstrukturen und Algorithm Skript
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Cemal, Mevludin
Datenstrukturen und Algorithm Skript
Commits
6f7b21ad
Commit
6f7b21ad
authored
Dec 16, 2020
by
Florian Unger
Browse files
Options
Downloads
Patches
Plain Diff
added a few pictures
parent
d2bc0973
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
304_Halden.tex
+58
-2
58 additions, 2 deletions
304_Halden.tex
with
58 additions
and
2 deletions
304_Halden.tex
+
58
−
2
View file @
6f7b21ad
...
...
@@ -33,9 +33,9 @@ definiert als $h(n) := \floor*{\log_2 n}$. Eine leere Halde hat die Höhe $h(0)
\label
{
fig:halde
_
array
}
\end{figure}
\begin{figure}
[
h
]
\begin{figure}
[
H
]
\centering
\in
cludegraphics
[scale=0.25]
{
bilder/Halde
_
baum
}
\in
put
{
bilder/heap
_
tree
_
representation.tex
}
\caption
{
Eine Halde aus Baumperspektive. Kindbeziehungen anstelle der Pfeile aus Abbildung~
\ref
{
fig:halde
_
array
}}
\label
{
fig:halde
_
baum
}
\end{figure}
...
...
@@ -152,6 +152,62 @@ n)$ hat. Die Laufzeit wird von den $\frac{n}{2}$ aufrufen von $\texttt{heapify}$
hat, eh dominiert. Also liegt die Laufzeit in
$
\mathcal
{
O
}
(
n
\log
n
)
$
. Damit ist
$
\texttt
{
heapsort
}$
also worst-case
optimal.
\begin{figure}
[H]
\centering
\input
{
bilder/heapsort
_
1.tex
}
\caption
{
Der Algorithmus
\texttt
{
heapsort
}
auf den Array
$
\mathcal
{
A
}
=
[
5
,
7
,
3
,
1
,
8
,
2
]
$
. Im ersten Schritt wird
(nacheinander, in dieser Reihenfolge)
\texttt
{
heapify
}
auf die Blätter mit den Werten
$
2
$
,
$
8
$
und
$
1
$
ausgeführt,
was jeweils keinerlei Effekt hat.
}
\label
{
fig:heapsort
_
1
}
\end{figure}
\begin{figure}
[H]
\centering
\input
{
bilder/heapsort
_
2.tex
}
\caption
{
Der Algorithmus
\texttt
{
heapsort
}
auf den Array
$
\mathcal
{
A
}
=
[
5
,
7
,
3
,
1
,
8
,
2
]
$
. Im zweiten Schritt wird
\texttt
{
heapify
}
auf den Knoten mit dem Wert
$
3
$
ausgeführt, also die Haldenbedingung zu seinem Kind
$
2
$
überprüft.
Da die Haldenbedingung für diesen Unterbaum nicht verletzt ist, passiert weiter nichts.
}
\label
{
fig:heapsort
_
2
}
\end{figure}
\begin{figure}
[H]
\centering
\input
{
bilder/heapsort
_
3.tex
}
\caption
{
Der Algorithmus
\texttt
{
heapsort
}
auf den Array
$
\mathcal
{
A
}
=
[
5
,
7
,
3
,
1
,
8
,
2
]
$
. Im dritten Schritt wird
\texttt
{
heapify
}
auf den Knoten mit dem Wert
$
7
$
ausgeführt, also die Haldenbedingung zu seinem Unterbaum
überprüft und gegenbenenfalls repariert. Da
$
8
$
größer ist als
$
7
$
, werden die beiden Werte getauscht.
}
\label
{
fig:heapsort
_
3
}
\end{figure}
\begin{figure}
[H]
\centering
\input
{
bilder/heapsort
_
4.tex
}
\caption
{
Der Algorithmus
\texttt
{
heapsort
}
auf den Array
$
\mathcal
{
A
}
=
[
5
,
7
,
3
,
1
,
8
,
2
]
$
. Im dritten Schritt wird
\texttt
{
heapify
}
auf den Knoten mit dem Wert
$
7
$
ausgeführt, also die Haldenbedingung zu seinem Unterbaum
überprüft und gegenbenenfalls repariert. Da
$
8
$
größer ist als
$
7
$
, werden die beiden Werte getauscht.
}
\label
{
fig:heapsort
_
4
}
\end{figure}
\begin{figure}
[H]
\centering
\input
{
bilder/heapsort
_
5.tex
}
\caption
{
Der Algorithmus
\texttt
{
heapsort
}
auf den Array
$
\mathcal
{
A
}
=
[
5
,
7
,
3
,
1
,
8
,
2
]
$
. Im dritten Schritt wird
\texttt
{
heapify
}
auf den Knoten mit dem Wert
$
7
$
ausgeführt, also die Haldenbedingung zu seinem Unterbaum
überprüft und gegenbenenfalls repariert. Da
$
8
$
größer ist als
$
7
$
, werden die beiden Werte getauscht.
}
\label
{
fig:heapsort
_
5
}
\end{figure}
\begin{figure}
[H]
\centering
\input
{
bilder/heapsort
_
6.tex
}
\caption
{
Der Algorithmus
\texttt
{
heapsort
}
auf den Array
$
\mathcal
{
A
}
=
[
5
,
7
,
3
,
1
,
8
,
2
]
$
. Im dritten Schritt wird
\texttt
{
heapify
}
auf den Knoten mit dem Wert
$
7
$
ausgeführt, also die Haldenbedingung zu seinem Unterbaum
überprüft und gegenbenenfalls repariert. Da
$
8
$
größer ist als
$
7
$
, werden die beiden Werte getauscht.
}
\label
{
fig:heapsort
_
6
}
\end{figure}
\subsection
{
Wartschlange (Priority Queue)*
}
Eine der häufigsten Anwendungen von Halden: Warteschlangen mit einer Priorität, bei der immer das dringenste (also das
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment