4. Announcements
The first homework will be online this Wednesday
with a deadline of next Wednesday.
Will deal with clarifications on Friday.
5. Announcements
The first homework will be online this Wednesday
with a deadline of next Wednesday.
Please take the informal survey on the website,
or send me an email with the subject [CS321].
Will deal with clarifications on Friday.
6. Graded Work
Google Code Jam Qualifiers (20%)
Self-assessment quizzes via MCQs online (25%)
Assignments on the Hacker Rank Platform (25%)
Mid-sem and End-sem Exams (30%)
12. At the start of each iteration of the for loop of lines 1–8,
the subarray A[1 . . j − 1] consists of the elements
originally in A[1 . . j − 1] but in sorted order.
16. Initialization
Maintenance
Termination
The statement is true at the beginning.
If the statement was true before the interation,
it is true after the iteration.
When the loop ends, the invariant gives us something useful.
17. At the start of each iteration of the for loop of lines 1–8,
the subarray A[1 . . j − 1] consists of the elements
originally in A[1 . . j − 1] but in sorted order.
18. At the start of each iteration of the for loop of lines 1–8,
the subarray A[1 . . j − 1] consists of the elements
originally in A[1 . . j − 1] but in sorted order.
19. At the start of each iteration of the for loop of lines 1–8,
the subarray A[1 . . j − 1] consists of the elements
originally in A[1 . . j − 1] but in sorted order.
27. Best-case running time
Average-case running time
Worst-case running time
There is some input on which the algorithm enjoys
this running time.
28. Best-case running time
Average-case running time
Worst-case running time
Work averaged over the space of all inputs.
There is some input on which the algorithm enjoys
this running time.
29. Best-case running time
Average-case running time
Worst-case running time
Work averaged over the space of all inputs.
No matter what the input, the algorithm will not need more
time than this.
There is some input on which the algorithm enjoys
this running time.
30. Worst-case running time
No matter what the input, the algorithm will not need more
time than this.
We’ll typically obtain lower and upper bounds
on the worst case running time.
31. Worst-case is sometimes too
pessimistic an approach.
Real-world inputs almost always
have some structure!