Beruflich Dokumente
Kultur Dokumente
September 2, 2016
Ryan Patrick
Outline
Homework Questions
Decrease-and-Conquer Algorithms
Decrease by a Constant
Topological Sorting
Combinatorial Objects
Decrease/Conquer
Patrick
Questions
Decrease &
Conquer
Constant
Topological Sort
Combinatorial
Objects
Permutations
Subsets
Permutations
Subsets
21
Outline
Homework Questions
Decrease-and-Conquer Algorithms
Decrease by a Constant
Topological Sorting
Combinatorial Objects
Decrease/Conquer
Patrick
3
Questions
Decrease &
Conquer
Constant
Topological Sort
Combinatorial
Objects
Permutations
Subsets
Permutations
Subsets
21
Homework Questions?
Decrease/Conquer
Patrick
4
Questions
Decrease &
Conquer
Constant
Topological Sort
Combinatorial
Objects
Permutations
Subsets
21
Outline
Homework Questions
Decrease-and-Conquer Algorithms
Decrease by a Constant
Topological Sorting
Combinatorial Objects
Decrease/Conquer
Patrick
Questions
5
Decrease &
Conquer
Constant
Topological Sort
Combinatorial
Objects
Permutations
Subsets
Permutations
Subsets
21
Decrease-and-Conquer Algorithms
Decrease/Conquer
Patrick
Questions
6
Decrease &
Conquer
Constant
Topological Sort
Combinatorial
Objects
Permutations
Subsets
21
Decrease by a Constant
Decrease/Conquer
Patrick
Questions
Decrease &
Conquer
7
21
Constant
Topological Sort
Combinatorial
Objects
Permutations
Subsets
Decrease by a Constant
Example: Factorial
Decrease/Conquer
Patrick
Questions
Decrease &
Conquer
8
21
Constant
Topological Sort
Combinatorial
Objects
Permutations
Subsets
Decrease by a Constant
Example: Factorial
Decrease/Conquer
Patrick
Questions
n!
Decrease &
Conquer
9
n (n 1)!
n 1 (n 2)!
..
.
21
Constant
Topological Sort
Combinatorial
Objects
Permutations
Subsets
Decrease by a Constant
Example: Insertion Sort
Decrease/Conquer
Patrick
Questions
Decrease &
Conquer
10
21
Constant
Topological Sort
Combinatorial
Objects
Permutations
Subsets
Topological Sorting
Decrease/Conquer
Patrick
Questions
Decrease &
Conquer
11
21
Constant
Topological Sort
Combinatorial
Objects
Permutations
Subsets
Directed Graphs
Decrease/Conquer
Patrick
Questions
Decrease &
Conquer
12
21
Constant
Topological Sort
Combinatorial
Objects
Permutations
Subsets
Topological Sort
Example: Course Prerequisites
Decrease/Conquer
Patrick
C1C1
C4C4
Questions
Decrease &
Conquer
13
C3C3
C2C2
C5C5
21
Constant
Topological Sort
Combinatorial
Objects
Permutations
Subsets
Topological Sort
Example: Course Prerequisites
Decrease/Conquer
Patrick
C1
Questions
C4
Decrease &
Conquer
14
C3
C2
C5
21
Constant
Topological Sort
Combinatorial
Objects
Permutations
Subsets
Topological Sort
Example: Course Prerequisites
Decrease/Conquer
Patrick
C1
Questions
C4
Decrease &
Conquer
15
C3
C2
C5
21
Constant
Topological Sort
Combinatorial
Objects
Permutations
Subsets
A. 1
16
B. 2
C. 3
D. 5
E. None of the Above
21
Constant
Topological Sort
Combinatorial
Objects
Permutations
Subsets
Permutations
Johnson-Trotter
Decrease/Conquer
Patrick
Questions
Decrease &
Conquer
17
21
Constant
Topological Sort
Combinatorial
Objects
Permutations
Subsets
Permutations
Lexicographical Order (Page 146)
Decrease/Conquer
Patrick
Questions
Decrease &
Conquer
1. First Permutation: 12 . . . n
2. i =largest index such that ai < ai+1
3. j =largest index such that ai < aj
18
4. Swap ai and aj
5. Reverse Order of ai+1 through an
6. Add Permutation to List
7. If Permutation Had Consecutive Elements in Increasing Order, Go to Step 2
21
Constant
Topological Sort
Combinatorial
Objects
Permutations
Subsets
Permutation
1234
1243
1324
1342
1423
1432
2134
i
3
2
3
2
3
1
3
j
4
3
4
3
4
4
4
2431
3124
1
3
3
4
3421
4123
1
3
2
4
4312
After Swap
1243
1423
1342
1432
1432
2431
2143
..
.
3421
3142
..
.
4321
4132
..
.
4321
DONE
After Reverse
1243
1324
1342
1423
1432
2134
2143
3124
3142
4123
4132
4321
Subsets
A = {a0 , a1 , . . . , an }
Decrease/Conquer
Patrick
Questions
Decrease &
Conquer
20
21
Constant
Topological Sort
Combinatorial
Objects
Permutations
Subsets
Any Questions?
Decrease/Conquer
Patrick
Questions
Decrease &
Conquer
21
21
Constant
Topological Sort
Combinatorial
Objects
Permutations
Subsets