Daniel Sutantyo, Department of Computing, Macquarie University
1.1 - Problems and Algorithms
1.1 - Problems and Algorithms
1.1 - Problems and Algorithms
1.1 - Problems and Algorithms
[ 5, 1, 7, 2, 6, 9, 11 ]
11
1.1 - Problems and Algorithms
[ 11, 9, 7, 6, 5, 2, 1 ]
[ 1, 2, 5, 6, 7, 9, 11 ]
[ ]
[ 1, 1, 1, 1, 1, 1 ]
[ 5.6, 4.1, 2.7, 2.1, 16.0, 9.1]
[ 5, 1, 7, 2, 6, 9, 11 ]
11
["chicken","beef","lamb"]
[null,null,null,null]
1.1 - Problems and Algorithms
1.1 - Problems and Algorithms
1.1 - Problems and Algorithms
1.1 - Problems and Algorithms
1.1 - Problems and Algorithms
1.1 - Problems and Algorithms
2
3
...
15
16
...
[2]
[3]
...
[3,5]
...
input
output
1.1 - Problems and Algorithms
[ 5, 1, 7, 2, 6, 9, 11 ]
11
[ 1, 2, 5, 6, 7, 9, 11 ]
[ 11, 9, 7, 6, 5, 2, 1 ]
[ 1, 1, 1, 1, 1, 1, 11 ]
. . .
[ 1 ]
1
. . .
[ 1, 1 ]
[ 1, 1, 1]
[ ]
???
1.1 - Problems and Algorithms
Wikipedia: a computational problem can be viewed as an infinite collection of instances together with a possibly empty, set of solutions for every instance
1.1 - Problems and Algorithms
1.1 - Problems and Algorithms
1.1 - Problems and Algorithms
1.1 - Problems and Algorithms
1.1 - Problems and Algorithms
no intermediate cities
1 intermediate city
\((n-2)\) choices
\(\vdots\)
A
A
B
B
\(\vdots\)
A
B
2 intermediate cities
\((n-2)(n-3)\) choices
1 choice
1.1 - Problems and Algorithms
$$ 1 + (n-2) + (n-3)(n-2) + (n-4)(n-3)(n-2) + \cdots + \binom{n-2}{k}k! $$
(via 1 city)
(via 2 cities)
(via 3 cities)
(via \(k\) cities)
50! = 30,414,093,201,713,378,043,612,608,166,064,768,844,377,641,568,960,512,000,000,000,000
1.1 - Problems and Algorithms
1.1 - Problems and Algorithms
13
63
44
22
93
21
72
67
1.1 - Problems and Algorithms
13
63
44
22
93
21
72
67
44
13
22
72
21
63
93
67
4 comparisons
3 comparisons
3 comparisons
1.1 - Problems and Algorithms
1.1 - Problems and Algorithms
Cartoon by Stefan Szeider, available at https://www.ac.tuwien.ac.at/people/szeider/cartoon/
1.1 - Problems and Algorithms
Cartoon by Stefan Szeider, available at https://www.ac.tuwien.ac.at/people/szeider/cartoon/
1.1 - Problems and Algorithms
Cartoon by Stefan Szeider, available at https://www.ac.tuwien.ac.at/people/szeider/cartoon/
1.1 - Problems and Algorithms
1.1 - Problems and Algorithms