-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathsortanim.html
More file actions
81 lines (73 loc) · 1.98 KB
/
sortanim.html
File metadata and controls
81 lines (73 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<HTML>
<HEAD>
<title>Sorting Algorithm Animations from Programming Pearls</title>
</HEAD>
<BODY BGCOLOR=#ffffff>
<a href="index.html">
<img alt="book cover" ALIGN=right hspace=20 src="pp2e.jpg">
</a>
<P>
<h1>Sorting Algorithm Animations from
<br><font color="#a52a2a">Programming Pearls</font></h1>
<p>
Column 11 describes Insertion Sort and two Quicksorts
(a simple version and the typical version using 2-way partitioning).
Column 14 describes Heapsort.
This page animates those algorithms and
two additional simple sorting algorithms
from the Solutions to Column 11:
Selection Sort and Shell Sort.
</p>
<p>
To view an animation,
hit the run button below.
Each dot represents an element in the array;
the x-value is the element's index and
the y-value is the element's value.
Thus a random array is a uniform smear of points,
and a sorted array is a trail of points wandering
from the bottom left to the top right.
</p>
<p>
To experiment with the algorithms,
select a value of n,
an input distribution,
and a sorting algorithm before hitting run.
For each algorithm,
be sure to start with a small value of n,
and work up to larger values.
WARNING!
There is no way to stop an animation in progress
(this is a simple Java program) other than by
terminating your browser.
Enjoy!
</p>
<hr>
<applet
code=SortAnim
width=650
height=400>
</applet>
<hr>
<p>
This animation shows the essential algorithms,
but has few bells and whistles.
Most of the algorithms sort the array a[0..n-1].
<b>BEWARE!</b>
The Heapsort takes a sleazy shortcut around the problem
of zero-indexed arrays:
it sorts the array a[1..n-1],
and leaves a[0] dangling in mid-air.
</p>
</ul>
The code for this animation is
<a href="SortAnim.java">SortAnim.java</a>,
available with the rest of the
<a href="code.html">source code</a>.
<p>
<FONT SIZE=1>Copyright © 1999
<B>Lucent Technologies.</B> All rights reserved.</FONT>
<font size=-2>
Fri 14 July 2000
</BODY>
</HTML>