-
Notifications
You must be signed in to change notification settings - Fork 57
/
complexity.html
176 lines (148 loc) · 5.29 KB
/
complexity.html
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<html>
<head>
<title>
COMPLEXITY - Execution Time as a Function of Problem Size
</title>
</head>
<body bgcolor="#EEEEEE" link="#CC0000" alink="#FF3300" vlink="#000055">
<h1 align = "center">
COMPLEXITY <br> Execution Time as a Function of Problem Size
</h1>
<hr>
<p>
<b>COMPLEXITY</b>
is a set of MATLAB programs which
investigate the time complexity of a few simple calculations.
</p>
<p>
Time complexity can refer to the relationship between problem size <b>n</b>
and execution time <b>t</b>. Algorithms may exhibit logarithmic,
linear, quadratic, or exponential time complexity. A quadratic time
complexity suggests that a formula such as <b>t = a + b * n + c * n^2</b>.
However, there is no point in trying to be so precise, and the important
feature here is the occurrence of <b>n^2</b>, whose growth rate will
eventually characterize the function. Thus, we tend to simplify such a
relationship by writing <b>t=O(n^2)</b>, saying "t is of the order of
the square of n". A more subtle complexity might have the form
<b>t = O(n * log(n) )</b>, which is a form that actually occurs fairly often.
</p>
<p>
For short, simple algorithms, it is possible to work out the time complexity
as a formula. However, practical algorithms often have complications that make
it tedious to seek such a formula. Moreover, the computer implementation
and the memory access patterns may also have a pronounced effect on the
behavior of a program, particularly when the problem size is large. Thus,
whether we can predict or estimate the time complexity of an algorithm, we
can experimentally measure it on a range of problem sizes and draw our own
conclusions.
</p>
<p>
In this directory, we consider a few simple algorithms, using them to solve
problems of increasing size, measuring the elapsed time, and making plots.
</p>
<h3 align = "center">
Licensing:
</h3>
<p>
The computer code and data files described and made available on this web page
are distributed under
<a href = "../../txt/gnu_lgpl.txt">the GNU LGPL license.</a>
</p>
<h3 align = "center">
Languages:
</h3>
<p>
<b>COMPLEXITY</b> is available in
<a href = "../../m_src/complexity/complexity.html">a MATLAB version</a>.
</p>
<h3 align = "center">
Related Data and Programs:
</h3>
<p>
<a href = "../../m_src/linpack_bench/linpack_bench.html">
LINPACK_BENCH</a>,
a MATLAB program which
measures the time taken by LINPACK to solve a particular linear system.
</p>
<p>
<a href = "../../m_src/mxm/mxm.html">
MXM</a>,
a MATLAB program which
sets up a matrix multiplication problem A=B*C of arbitrary size,
and compares the time required for IJK, IKJ, JIK, JKI, KIJ and KJI orderings
of the loops.
</p>
<p>
<a href = "../../m_src/nas/nas.html">
NAS</a>,
a MATLAB program which
runs the NASA kernel benchmark.
</p>
<p>
<a href = "../../m_src/tic_toc/tic_toc.html">
TIC_TOC</a>,
MATLAB programs which
demonstrate some features of MATLAB's tic and toc functions for wallclock timing.
</p>
<h3 align = "center">
Source Code:
</h3>
<p>
<b>BUBBLESORT_COMPLEXITY</b> considers the time complexity of the bubblesort algorithm.
<ul>
<li>
<a href = "bubblesort_complexity.m">bubblesort_complexity.m</a>,
the source code.
</li>
<li>
<a href = "bubblesort_1to200.png">bubblesort_1to200.png</a>,
plots the time require for problem sizes N = 1, 2, 3, ..., 200.
</li>
<li>
<a href = "bubblesort_powersoftwo.png">bubblesort_powersoftwo.png</a>,
plots the time require for problem sizes N = 1, 2, 4, 8, 16, ..., 2^12.
</li>
</ul>
</p>
<p>
<b>ELIMINATION_COMPLEXITY</b> considers the time complexity of Gauss elimination.
<ul>
<li>
<a href = "elimination_complexity.m">elimination_complexity.m</a>,
the source code.
</li>
<li>
<a href = "elimination_1to200.png">elimination_1to200.png</a>,
plots the time require for problem sizes N = 1, 2, 3, ..., 200.
</li>
</ul>
</p>
<p>
<b>HEAPSORT_COMPLEXITY</b> considers the time complexity of the heapsort algorithm.
<ul>
<li>
<a href = "heapsort_complexity.m">heapsort_complexity.m</a>,
the source code.
</li>
<li>
<a href = "heapsort_1to200.png">heapsort_1to200.png</a>,
plots the time require for problem sizes N = 1, 2, 3, ..., 200.
</li>
<li>
<a href = "heapsort_powersoftwo.png">heapsort_powersoftwo.png</a>,
plots the time require for problem sizes N = 1, 2, 4, 8, 16, ..., 2^12.
</li>
</ul>
</p>
<p>
You can go up one level to <a href = "../m_src.html">
the MATLAB source codes</a>.
</p>
<hr>
<i>
Last revised on 23 December 2012.
</i>
<!-- John Burkardt -->
</body>
<!-- Initial HTML skeleton created by HTMLINDEX. -->
</html>