Lecture-14_student
Lecture-14_student
Algorithms
x y( x y )
x( | x )
1 Chapter 3
x 1
x
?
x 1
x ?
RIZOAN TOUFIQ
ASSISTANT PROFESSOR
DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING
RAJSHAHI UNIVERSITY OF ENGINEERING & TECHNOLOGY
Chapter Summary
Algorithms
– Example Algorithms
– Algorithmic Paradigms
Growth of Functions
– Big-O and other Notation
Complexity of Algorithms
Algorithms
Section 3.1
Section Summary
Properties of Algorithms
Algorithms for Searching and Sorting
Greedy Algorithms
Halting Problem
Problems and Algorithms
At the first pass the largest element has been put into the correct position
At the end of the second pass, the 2nd largest element has been put into the correct
position.
In each subsequent pass, an additional element is put in the correct position.
Insertion Sort
Insertion sort begins with the 2nd element. It compares the 2nd
element with the 1st and puts it before the first if it is not larger.
procedure change(c1, c2, …, cr: values of coins, where c1> c2> … > cr ;
n: a positive integer)
for i := 1 to r
di := 0 [di counts the coins of denomination ci]
while n ≥ ci
di := di + 1 [add a coin of denomination ci]
n = n - ci
[di counts the coins ci]
Start: 9:00 AM
Talk 1
Talk 2 Start: 9:45 AM
End: 11:00 AM
x 1 x ? 1
x 1
x
?
1
1 2 3 4.... ?
1 1 1 1 1......... ?
x 1
x
?