Introduction to Algorithms
6.046J/18.401J
L
ECTURE
1
Analysis of Algorithms
• Insertion sort
• Asymptotic analysis
• Merge sort
• Recurrences
Prof. Charles E. Leiserson
Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson
September 7, 2005 Introduction to Algorithms L1.2
Course information
1. Staff
2. Distance learning
3. Prerequisites
4. Lectures
5. Recitations
6. Handouts
7. Textbook
8. Course website
9. Extra help
10. Registration
11. Problem sets
12. Describing algorithms
13. Grading policy
14. Collaboration policy
September 7, 2005 Introduction to Algorithms L1.3
Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson
Analysis of algorithms
The theoretical study of computer-program
performance and resource usage.
What’s more important than performance?
• modularity
• correctness
• maintainability
• functionality
• robustness
• user-friendliness
• programmer time
• simplicity
• extensibility
• reliability
September 7, 2005 Introduction to Algorithms L1.4
Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson
Why study algorithms and
performance?
• Algorithms help us to understand scalability.
• Performance often draws the line between what
is feasible and what is impossible.
• Algorithmic mathematics provides a language
for talking about program behavior.
• Performance is the currency of computing.
• The lessons of program performance generalize
to other computing resources.
• Speed is fun!
September 7, 2005 Introduction to Algorithms L1.5
Copyright © 2001-5 Erik D. Demaine and Charles E. Leiserson
The problem of sorting
Input: sequence 〈a
1
, a
2
, …, a
n
〉 of numbers.
Output: permutation 〈a'
1
, a'
2
, …, a'
n
〉 such
that a'
1
≤ a'
2
≤
…
≤ a'
n
.
Example:
Input: 8 2 4 9 3 6
Output: 2 3 4 6 8 9