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

LECTURE 2 SEP 22

of a list

max value

Find

LOOPINVARIANT
Max A n
find

value in Afo i

man contains largest

I make ALB TERMINATION

contains largestvalue in A m
man

n for Citi N D

n I if Ali Max TL 2ntfCDH

3mHz OLD
WC

ottoman man Ali

anti L n BL

1 return Max

TC Acn

about the asymptotic largest

0,1 I we are talking

values

Find it allelements are distinct


T'sDistinct A D
yousee a loop try


When


sont A finding loop invariant
HINT Dryrun in mindis

for its ton 2


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

for i 0 Max Gunter is 0 for all ago if



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

return true FASTER


to O manta

Find Max using recursion

TCM RecRe TED Th D 4

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

You might also like