You are on page 1of 19

Wedell start at 7:32

if Euchring → It involves
,

that
some set
of
elements &
searches
a

target
we want to

Linear Seance Consider have list


* →

you
a
of
numbers
,
and
you
have to search
for a
target
Nimby .

St
says
iterate one
by one on all the elements
,
& if
the aural is
elements
efual to the
target ,
octane
in den
of cure
element
FEDELI
targe -o±
.

joiineaihe
possibilebj
¥§gD
we

:÷÷÷÷÷÷fe ec→⑧sc→o
.
worst case scenario when don't even

you

have element
the
present or the element can

beat last indene as Ocn )


=

Best Case Scenario -


element is
present atom

under → SLG )
=
cries
I a) list of equal elements ]

)
⑦ 0¥
÷
.IE;
-

Ty
a unsorted list

c) Sorted list about me

pumubaln
d) abou ←
- ally gene
all
(i )
the words
will
week
never have startingcharacter
introduce
greater nm
also data
Maybe can in a
arrange
we

specific marines

=
|BinaeyfeawJ
some

taste ①
elements

w.fi?lemsaYen.#Y., I&,XsY9Iolit3H6lEooythein
Vad n - n .
, → n -
z→ . . .
. -

Linear
~rmearb=
z
-
n
z nz
- -

ng
-
-
-
- -
- - - -

/£e → k=
logan
eg-ouog

( →
n → 103 - O Cn ) → 103
)
Ollogn
-
to

n→1O° - Cn ) a 106
Olcogn) x do

n -109 →
Oln ) a 109

oclognl =±

S 27
9 10 13 19 21
a) list of equal
elements

D unsorted list

c) Sorted list

d) all
of
abou
#
Binary search

can be
applied on all those Search condition where

we can divide the search


space into a
parts
Such that the 2 parts are
distinguishable
based on Some
property
① ← 1¥
1
g.
unsorted

10 Is
-3 6,8 0 I
?
,
, , , , ,

unsorted ←
from a sorted lest which has

been rotated -

-
x l S S
O l 2 3 6 8 10

-
X f 3 6 8 IS b
, , , ,
1,0 ,

IS O
#c 3 1 61 8
l
l 0
, , , I

3, 6 , 8 , I 01 IS , 011,2
target ←
rylt
° i 2 h s
f t
3

19 4S
steak 56,68
0
, , , , ,

left right mid


0 7 3

0 & M
I

Q Q &
.

TC
SC
SCD are
=
OCD
Ocdogn ) =
Oct

Ociogn )
← /d r
-
lmin.mn#

i⑦E1e. !
.

]
2147283697 →
man

-2147483648g
- min
mid→d- -

modified

d# adage

"
¥

-
⇐ Binary seamen on sorted rotated lest

lshof,,!f""km
dpqadqq.eu
valid n

,
Subh
,
sweet
up
i
i :/
I Ende
mid
y
!

I
6,0 2 3
S I
, , , , ,

afsta.TT
casey

y÷%~fiuotpoi
valin

"

"

Hit i.
I
'

"
www.suon I
,

Ende
)
¥ .
,

afsta.tt#mid !

I
6,0 2 3
S I
, , , , ,

afstao#mdJ
case
Can
'
we
doit
using single binary
case 2
seared
target I came


do
! u.edu ,

i
k
Ollogn) l
l
Scioli ) l
l -

i 1

! I
'

.
I
'
!

Man ( star ) <


asslmid] w¥anlstaD>awmidT
awls ) and Ts=awlmidT
-
→ T >
T > = mid and Teer
↳ right -
- mid -
i

else
↳ left -_ mid - I

You might also like