Professional Documents
Culture Documents
Lecture1 - Data Structures and Algorithms
Lecture1 - Data Structures and Algorithms
DESIGN
ANALYSIS OF ALGORITHMS
HienVu
9 00 to 10 30 am Monday 90WTHAM
WI 607812
As a programmer don'thave
SEARCHING
PSEUDOCODE
PROVING
Search A X
n tou canprovebyprovinglinebyline
1 0 LOOP INVARIANT
while i can D
X n If invarianttrue at beginning
32 1 0 n
it i n
return False I
PROVING
goth
MATHEMATICAL
INDUCTION
initial value
DProve for base
case
is true when n K
2 Assume statement
mkt
Use that to prove for
3
as true and prove
other part
t isnotin ALo if
TERMINATION
INITIALISATION found false
is
i N
Y notis C in
n
is notin A
o
A AB Y
MAINTENANCE
found true
found false
a
ALOT
It Y is in Alo
HOME LEARNING s
Ex assert Go 5
PRE
We need to
assure loops
in that
it terminates
itproduces
LOOP IN VARIANT
PROVING CORRECTNESS
4 For programs