Professional Documents
Culture Documents
Lecture2 - Data Structures and Algorithms
Lecture2 - Data Structures and Algorithms
of a list
max value
Find
LOOPINVARIANT
Max A n
find
value in Afo i
contains largestvalue in A m
man
n for Citi N D
3mHz OLD
WC
anti L n BL
1 return Max
TC Acn
values
T'sDistinct A D
yousee a loop try
When
sont A finding loop invariant
HINT Dryrun in mindis
A it closely
associated tofinding LD
it Ali
returnfalse Loop inv Aco i D are distinct
return true
to O InDgp
is Distinct A D sort
count Oln soln forintegers
create count o max bestsolution
LI
o
county
O N l L I
for j
count ALOT L
LI CountACID L
for i t Max
ton all Alo i
it count i I return false
findMax Ani
METHODS
if i n I 1
Backsub
return Ali I
Rec tree
m find Max A
n
itD Tony
Master's thesrom
it Ali m I
M ALI I TCO n
return m 1
SORT TECHNIQUE
USING MERGE
3 find Max
A N i
j
if i j
Redel Ten stay
return agg
TC 0Ln
I
m
Lito 2
find
Mak Am
i m Nz
m
left
n2
Am Mt'd
night find
m
mex
then I
it left might
m
returnmlett
It
else
return might