0% found this document useful (0 votes)
2 views

Algorithm_Unit_1

The document discusses various searching algorithms including sequential search, binary search, and interpolation search, along with their time complexities. It also touches on sorting techniques such as heap sort and string matching algorithms. Additionally, it covers asymptotic analysis and the notation used to describe algorithm efficiency.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Algorithm_Unit_1

The document discusses various searching algorithms including sequential search, binary search, and interpolation search, along with their time complexities. It also touches on sorting techniques such as heap sort and string matching algorithms. Additionally, it covers asymptotic analysis and the notation used to describe algorithm efficiency.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

ps 12

Key
lhe
);
seanch (key)
search
seuenial
sequental.
oulput
by
atb
tateen &7
to
aeanch 7
add ();data
get
alcen 12 leey
intwducton l 85 87 n,
algoülhm
| Tme
compater nca case
case
Std: Cio,
comple
sly "75
ream,
leity
techruues
(on)Search 3 5 Average
cse
ace
amesp a
Seanch :private
Comp
J worstst nt Pubie:
d vod
1,
Bet <jo SeaIch
::
Soquenlia Seaneh
Space Binay 75 nclude
Time
i) Soan
ohung Seguential 3,
Input wsing
clan Voud
) 2, # 3;
for (i= o; iLn; í+t)

flag l ;
cout cL " Flenent fourd;
3
Ele
cout ce" Not found ";
break;

3
Search :: get. dato ()
cOut lL ow element. mary elements
are the,aay

out le Entos element ";.


for (i e 0; i }n :i+ t) '
Cin > a ct3i
3
main ()

Dbù. get_ dala(0;


cout LL Erton the olements Learch:

sequent). seanch ( cey)s


3
output Enton How mary elemont o the

95 50 75

eay
¬lerment found.
Birary seanch
3
c0y - 70
20 30 6o "70

low
high
mid Low +high " D47 &5
-|3
80
mid
Lorw high
program
# nclde Laosteam, h>
uArg namesp ace Std;
olass Bnaysearch
Priw ate :
Public :
nt Aow, hig ;
BS (
nt get_ dala (2;
bin Soaich ( ;
33

nt total no of elements:";
enten

List ot elemets: ':


Cout zz enton the
itt)
for (ieO ; iLn ;
cç a [i]:
Jewn n;
Buncvy Sean ch ().
seanch :: bnsaar
cnt mid
mid

rolwn Crrid

bçstanch ( mid-1) ;.
ele
bin seanch ( mid tI)}
3
Vo main ( )
nt koy;
BS obý;
obi. getvalue (3;
obj. bin sQonch ();
Cout cL entor the

3
Output :
enten total elomerts 5
entor the 'list tot elemerts 2

enten the

key found at 2 nd posttion.


Lntepolation Soanch
22| 2

5 7
low
löw t

o+(7-o)x (32-10)/
f7x21

Tnselon Sort

SOt the elomert gwen wVay


as cending oiler using hoap sort.
The eloments 48, 0,-l, 8;2,o 72,54.

G854| 32(08

string matchg algohm


patlenn

Tent
2
5 7 13 y
Length

shift

Shifl o

shll
S2

S3 ooo
Su
Ss
Sh

Sq
Sto

S=l S=5 thoe thee the elemon


ae matchad:
T= RAMAN LT KES MANGIOES
P = MAN

Robin korp olaonilhn


5
6 3 5

etin
l4 l 3 (No match ) Hoash fun

" 4 (sP auous hit )


9$ 3s , 10 4 (Sputious hiE)
92%. I1: k 4(sputurus hit)
(Eact pib)
(no match)
53. Il (vo malch )
357, l| ) ( No motch)
Spwúows hit
o e Fzoct ht, fou1
Alqouthun
radix
m
3 mocd 4
(ibitiai'e)

6. fo to n

7. do

4. to, n-m)
10, P= ts
pLnt Palttern maths with
tren,
shi<t ", s)

Tet
P Patten
vaiance

decinal digil
to tet decinal
kruth Movis patl Algoilhm
Stng b

paller " ab a b d X prob

patlenn to gi
Va

Put d
vae

13m AsymptoloAnaly
to `sprOS the
ExQcutin algo üthm and
also the
tHaincy ot
Vauow algonithn
UAirg Asyrp toic Aralysis
vey coTcde best cese, wOns t
and Case
aweragl Scenaio
an
olgorithm
Hs yp to ic Aralysis jers comp bing
the Gne ot ary operation in
mathemaical urit
+sre space
o (big on) Cuppn bound complely
2. (omega) . louwen bound
3
e (Thota ) - Midle bounded.

where
tin) - Ruriq time paagram eBenlion
9cn) - Sunpte tundlion to Compar0

the eount.
O- notaion
t

tln)

no

(znput)
tin) 4 Co 9 (n)
said to be ol9en))
A tuncion tin)
tin) i brurdod
donoloo tn) ¿ o(9(n)), if
cons tant. g(n).
above

- (omega)
t
t (n)
-c. gun)

t (n) (o9t0)
Said to bo
tmelion tln)
(9tn)), if,
(9nT) denotod
boundod below constant

myliplo o 9u).
9- (Thela )

(tme) t(n)

4.9(0)

(. gn) tin) Co.9tn)


i Said to be
tuncion ttn)
tve
(9cna so
(9tn), denotod tin) í 0
mulliplies ot 9n).
coTstant

You might also like