LAB2 Agenda

Room

08:30- 10:30
Data Structures and Algorithms Ex C LAB D002 Lecture room, Ser-D

Quick remainders

Important Remainder

Comments on the assignements

Intro for today

Coding for today

Insertion Sort:

for j := 2 to n do // A[1..j-1] sorted 
    key := A[j]; 
    i := j-1;
    while i > 0 and A[i] > key do
        A[i+1] := A[i];  
        i--;
    A[i+1] := key

Bubble Sort:

for j := 2 to n do // A[1..j-2] sorted and minimum 
    for i := n to j do
        if A[i-1] > A[i] then 
            swap A[i-1] and A[i]