Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

SEP 20

DESIGN

ANALYSIS OF ALGORITHMS

HienVu

9 00 to 10 30 am Monday 90WTHAM

WI 607812

6 chapters from book LRS

Any language for assignments tests

classes uses pseudocode recommended for us as well

HW Deadline Sunday 11.59pm

As a programmer don'thave

SEARCHING

2 returns Ci exit point

PSEUDOCODE

PROVING

Search A X

n tou canprovebyprovinglinebyline

1 0 LOOP INVARIANT

ntl next page

while i can D

X n If invarianttrue at beginning

if Afi it will be truefor next its


return true

32 1 0 n
it i n

Gin our classprove

return False I

PROVING

Simple steps small prove by line by line

2 Loop Loop Invariant are some

goth

3 Recursion Mathematical Induction

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

use nah take it

LOOPINVARIANT D found is false

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

ASSERTION Statement that is


either True or FalseCbools

used in programming as a condition

Ex assert Go 5

PRE

CONDITION Requires a boolean condition satisfied

before start of the function

POST CONDITION Requires boolean condition met at the

end of the function

We need to

assure loops
in that

it terminates

the desired output

itproduces

Inorder to get there


we use a concept called LoopINVARAN

LOOP IN VARIANT

A boolean condition that is true

at the beginning of theloop and at

the end of each iteration


WHY STUDY LOOP INVARIANTS

To prove propertiesof theloops

To prove partial correctness of the loops

HOW TO FIND A LOOPING INVARIANT

Prove condn is true in the beginning beforelooping

Prove condn is true at each iteration one iteration

Prove loop termination condition

PROVING CORRECTNESS

For simple programs line by lineprove

For loops with numbers unwind prove

For loops with variables loop invariant

4 For programs

with recursion Math Induction

usedfor loops as well

You might also like