Professional Documents
Culture Documents
t.BIGIDF.FI
.
Linear search
2.
Binary Search
j .
Linearsearch :
Oln)
running time
:
worst case
=
Divideonquermehoa :
(E) +1
{
" , if n> ,
1- (n) =
otherwise
I,
←
search left of list Ten) =
2T[É) -11
=
4T (E) +2 =
. . .
=
ntci) +
log n
=Ñ now ?
check if approach
Then)= T (E) + 1- (E) ✓ correct
=TÉD¥ ) 2910812021
Tcu) =
2T / E) + I
↳
it ( is ;)
ii.
Binarysearch
l<=xlu1s=nT_
left !
0
thecde : .
whyi.it#rrect?
→
use # assertion
otherwise
Ten) After
=
1
,
with 42 . another comparison, left with
steps one
Ten) =
T (1) +1 element in list .
=T (E) +2 =
. . . .
=T (F) +k =
. . .
now?
1- G) +
login
#
=
=D ( logis)