E N D
1. 1 CSCE 310: Data Structures & Algorithms
2. 2 Time efficiency of nonrecursive algorithms Steps in mathematical analysis of nonrecursive algorithms:
2. As a rule, the basic operation is located in its inner-most loop
3. Check whether the number of times the basic operation is executed depends only on the size of an input. If it also depends on some additional property, the worst-case efficiencies
4. After that, we will set up a sum expressing the number of times the algorithms basic operation is executed
5. either to find a closed-loop form formula for the count or, at the very least, establish its order of growth2. As a rule, the basic operation is located in its inner-most loop
3. Check whether the number of times the basic operation is executed depends only on the size of an input. If it also depends on some additional property, the worst-case efficiencies
4. After that, we will set up a sum expressing the number of times the algorithms basic operation is executed
5. either to find a closed-loop form formula for the count or, at the very least, establish its order of growth
3. 3 Time efficiency of nonrecursive algorithms Steps in mathematical analysis of nonrecursive algorithms:
Decide on parameter n indicating inputs size
Identify algorithms basic operation
Determine worst, average, & best case for inputs of size n
Set up summation for C(n) reflecting algorithms loop structure
Simplify summation using standard formulas (see Appendix A)
2. As a rule, the basic operation is located in its inner-most loop
3. Check whether the number of times the basic operation is executed depends only on the size of an input. If it also depends on some additional property, the worst-case efficiencies
4. After that, we will set up a sum expressing the number of times the algorithms basic operation is executed
5. either to find a closed form formula for the count or, at the very least, establish its order of growth2. As a rule, the basic operation is located in its inner-most loop
3. Check whether the number of times the basic operation is executed depends only on the size of an input. If it also depends on some additional property, the worst-case efficiencies
4. After that, we will set up a sum expressing the number of times the algorithms basic operation is executed
5. either to find a closed form formula for the count or, at the very least, establish its order of growth
4. 4 Series Proof by Gauss when 9 years old (!):
5. 5 General rules for sums
6. 6 General rules for sums
7. 7 Examples: Matrix multiplication
Section 2.3
Selection sort
Section 3.1
Insertion sort
Section 5.1
These are some good examples to analyze in class, mostly from later sections
of the book:
Matrix multiplication (section 2.3)
Selection sort (section 3.1)
Insertion sort (section 5.1)
These are some good examples to analyze in class, mostly from later sections
of the book:
Matrix multiplication (section 2.3)
Selection sort (section 3.1)
Insertion sort (section 5.1)
8. 8 Matrix multiplication The element of matrix C: C[i, j] is computed as the scalar products of the ith row of matrix A and the jth column of matrix BThe element of matrix C: C[i, j] is computed as the scalar products of the ith row of matrix A and the jth column of matrix B
9. Sorting problem Given a list of n orderable items, rearrange them in a non-decreasing order
9
10. Sorting problem Given a list of n orderable items, rearrange them in a non-decreasing order
Selection Sort
E.g. 3, 7, 8, 2 10
11. 11 Selection sort
12. Sorting problem Given a list of n orderable items, rearrange them in a non-decreasing order
Insertion Sort
E.g. 5, 2, 9, 1
12
13. 13 Insertion sort
14. In-class exercises
14 P67 2.3.1 (c) & (d)
P68 2.3.10 (a) & (b)