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
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Unger, Florian Fedor Fridolin
Datenstrukturen und Algorithm Skript
Commits
b4fdbb0e
Commit
b4fdbb0e
authored
4 years ago
by
Florian Unger
Browse files
Options
Downloads
Patches
Plain Diff
fixed radixsort and added a bit more explanation of th syntax
parent
1a9ce9c8
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
204_Radixsort.tex
+6
-5
6 additions, 5 deletions
204_Radixsort.tex
with
6 additions
and
5 deletions
204_Radixsort.tex
+
6
−
5
View file @
b4fdbb0e
...
...
@@ -5,7 +5,8 @@ Der Sortieralgorithmus \texttt{radixsort} ist ein Beispiel für ein nicht vergle
arbeiten ohne Vergleiche und müssen daher zusätzliche Annahmen über den Input machen. Wir fordern also, dass unser aus
$
n
$
Elementen bestehender Input jeweils eine gleiche Anzahl von Stellen
$
d
\in
\mathbb
{
N
}$
hat. Pro Stelle haben wir
dabei
$
b
$
verschiedene Möglichkeiten. Beispielsweise besteht
\texttt
{
``beispiel''
}
aus
$
d
=
8
$
Buchstaben, von denen es
$
b
=
26
$
gibt. Die Dezimalzahl
$
9215
$
hat hingegen
$
d
=
4
$
Stellen mit jeweils
$
b
=
10
$
Möglichkeiten.
$
b
=
26
$
gibt. Die Dezimalzahl
$
9215
$
hat hingegen
$
d
=
4
$
Stellen mit jeweils
$
b
=
10
$
Möglichkeiten. Wir referenzerieren
auf die
$
i.
$
Stelle von
$
x
$
mit
$
x
_
i
$
. Beispielsweise ist mit
$
x
=
423
$
:
$
x
_
0
=
4
$
,
$
x
_
2
=
3
$
.
Hat man Zahlen/Wörte von unterschiedlicher Länge, muss man sie von der passenden Seite mit Lückenfüllern auffüllen, im
Fall von Zahlen also von links mit
$
0
$
.
...
...
@@ -18,13 +19,13 @@ Reihenfolge). In der Sammelphase werden alle Kategorien entsprechend ihrer Ordnu
\begin{algorithm}
[H]
\SetNlSty
{
texttt
}{
[
}{
]
}
\caption
{$
\texttt
{
radixsort
}
(
\mathcal
{
Q
}
)
$}
\KwIn
{
An unsorted Queue
$
\mathcal
{
Q
}$
of leng
h
t
$
n
$}
\KwIn
{
An unsorted Queue
$
\mathcal
{
Q
}$
of lengt
h
$
n
$}
\KwOut
{$
\mathcal
{
Q
}$
, but sorted
}
$
\text
{
Initialize Queues
}
\mathcal
{
Q
}_
0
,
\dots
,
\mathcal
{
Q
}_{
b
-
1
}$
\;
\For
{$
i
\leftarrow
d
-
1
$
\KwTo
$
0
$}{
\While
{$
\mathcal
{
Q
}$
\emph
{
is not empty
}}{
$
x
\leftarrow
\texttt
{
get
}
(
\mathcal
{
Q
}
)
$
\;
$
\texttt
{
put
}
(
\mathcal
{
Q
}_{
x
_
i
}
, x
_
i
)
$
\;
$
\texttt
{
put
}
(
\mathcal
{
Q
}_{
x
_
i
}
, x
)
$
\;
}
\For
{
$
j
\rightarrow
0
$
\KwTo
$
b
-
1
$}{
\While
{$
\mathcal
{
Q
}_
j
$
\emph
{
is not empty
}}{
...
...
@@ -41,7 +42,7 @@ letzten $i$ Stellen, sortiert sind.
Eine wichtige Bedingung für die Korrektheit der Sammelphase ist, dass die vorige Reihenfolge innerhalb der Fächer
aufrechterhalten wird.
Die Laufzeit von
\texttt
{
radixsort
}
betr
a
gt
$
T
_{
\text
{
rs
}}
(
n
)
=
\mathcal
{
O
}
(
d
\cdot
n
)
$
, ist also linear, wenn die
Die Laufzeit von
\texttt
{
radixsort
}
betr
ä
gt
$
T
_{
\text
{
rs
}}
(
n
)
=
\mathcal
{
O
}
(
d
\cdot
n
)
$
, ist also linear, wenn die
Anzahl der Stellen
$
d
$
als konstant betrachtet wird.
In diesem Fall ist
\texttt
{
radixsort
}
asymptotisch schneller als vergleichsbasierte Sortierverfahren, hat aber einen
erhöhten Speicherbedarf
(TODO: Stimmt das wirklich? Implementierung mit Queues scheint ziemlich sparsam)
.
deutlich
erhöhten Speicherbedarf
, welcher insbesondere linear in der Anzahl der Fächer
$
b
$
wächst
.
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