COP 4531: Lecture 2
Learning objectives
After this class, you should be able to:
- Given an array, show the steps executed by
INSERTION-SORT
.- Prove the correctness of insertion sort, using loop invariants.
- Write code to implement insertion sort.
- Give the asymptotic time complexity of insertion sort.
- Given an algorithm similar to insertion sort, prove its correctness and determine its time complexity.
Reading assignment
- CLR: Sections 2.1 - 2.2, prepare for the test on pre-requisite materials.
- CLR: Chapter 2, pages 29 - 31.
Exercises and review questions
- Questions on current lecture's material
- Exercise 2.1-1.
- Exercise 2.1-3.
- Exercise 2.2-2.
- Questions on next lecture's material
- Let an array
A
contain the elements:3, 26, 41, 52, 9, 38, 49, 57
. Show the steps taken by the procedureMERGE
operating on A withp = 1, q = 4, r = 8
.