Lecture1 Intro
Lecture1 Intro
CSCE 310J: Data Structures & Algorithms CSCE 310J: Data Structures & Algorithms
http://www.cse.unl.edu/~goddard/Courses/CSCE310J
Design and Analysis of Algorithms - Chapter 1 1 Design and Analysis of Algorithms - Chapter 1 2
Design and Analysis of Algorithms - Chapter 1 3 Design and Analysis of Algorithms - Chapter 1 4
Algorithmic solution
Design and Analysis of Algorithms - Chapter 1 5 Design and Analysis of Algorithms - Chapter 1 6
1
Design and Analysis of Algorithms Chapter 1
• Output: A reordering of the input sequence <a´1, a´2, …, a´n> I Output: array a sorted in non-decreasing order
so that a´i ≤ a´j whenever i < j
I Algorithm:
I Instance: The sequence <5, 3, 2, 8, 3>
I Algorithms:
• Selection sort for i=1 to n
• Insertion sort swap a[i] with smallest of a[i],…a[n]
• Merge sort
• (many others)
• see also pseudocode, section 3.1
Design and Analysis of Algorithms - Chapter 1 7 Design and Analysis of Algorithms - Chapter 1 8
I Program termination
I Optimality
Design and Analysis of Algorithms - Chapter 1 9 Design and Analysis of Algorithms - Chapter 1 10
Design and Analysis of Algorithms - Chapter 1 11 Design and Analysis of Algorithms - Chapter 1 12
2
Design and Analysis of Algorithms Chapter 1
Correctness Complexity
I Termination I Space complexity
– Well-founded sets: find a quantity that is never negative and I Time complexity
that always decreases as the algorithm is executed – For iterative algorithms: sums
I Partial Correctness – For recursive algorithms: recurrence relations
– For recursive algorithms: induction
– For iterative algorithms: axiomatic semantics, loop invariants
Design and Analysis of Algorithms - Chapter 1 13 Design and Analysis of Algorithms - Chapter 1 14
Design and Analysis of Algorithms - Chapter 1 15 Design and Analysis of Algorithms - Chapter 1 16