Dsa Class01
Dsa Class01
ID2230
Lecture 01
30 Jul 2024
Course Logistics
Databases
Operating Systems
Computer Networks
Image processing
Computer Graphics
Cybersecurity
Data Science & Machine Learning
Goals
Algorithm
1: procedure Insertion Sort(a1 , a2 , . . . , an )
2: for i=2 to n do
3: Insert ai at j + 1: aj < ai < aj+1 .
4: end for
5: end procedure
Algorithm: The Insertion Step
Algorithm
1: procedure Insertion Step(a1 , a2 , . . . , an , i)
2: for j=i-1 to 1 do
3: If aj+1 < aj , swap aj+1 and aj .
4: end for
5: end procedure
Algorithm: Insertion Sort
Algorithm
1: procedure Insertion Sort(a1 , a2 , . . . , an )
2: for i=2 to n do
3: for j=i-1 to 1 do
4: If aj+1 < aj , swap aj+1 and aj .
5: end for
6: end for
7: end procedure
Correctness and efficiency