0% found this document useful (0 votes)
5 views14 pages

Algorithm Design Techniques

The document outlines various sorting and searching algorithms, including Quick Sort, Merge Sort, Linear Search, and Binary Search, along with their implementation in C. It also includes examples of input and output for each algorithm. Additionally, there are sections on matrix chain multiplication and finding the longest common subsequence.

Uploaded by

abhi8609073
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)
5 views14 pages

Algorithm Design Techniques

The document outlines various sorting and searching algorithms, including Quick Sort, Merge Sort, Linear Search, and Binary Search, along with their implementation in C. It also includes examples of input and output for each algorithm. Additionally, there are sections on matrix chain multiplication and finding the longest common subsequence.

Uploaded by

abhi8609073
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

Signature Teacher's

returnitly
temp [has] arr
[high an Li+1] arr
Li+U arr temp int
temps
arr
Liarr temp mt
anlashl piat
higbA htlow, it L, arr partiion ot
Ciat
pisls (arr, Sort quck
pi-D: high, Low, Cam, quick
So
hiph) lod, Car, partitian pi nt oo
hiLh) int dow, intarJ,
Sort quik bid Cint
hiqh) nt
low, arrCl,
nt partition
Cint int
high), int dow, nt I,arr quickSort
Cint
void
<stdiah clude
sort Quick
kupenimenl
No. Page 1 No. Expt.
Date
Date

Expt. No. Page No.

fot arr [Jel0, 5, 8,,6ij


int n a Size of_ Car)s2eof Car Lo);
prntf (" Oriainal artay : "

prit f C"n
uikSort Cart, O, n-di
paiotf CSoxted aayi ");
printf C" Zd, art Li),
xeturn O,

Teacher's Signature
aray i |0 5 % 16
ar : 5 6 8 10
Sorted aray
Date

Expt. No. Page No.

Me~ge Sort

#aclude <stdoh
Noid mere Cint_arr Ll,_ntl, int m, nt rei
e
Dt nl m-+l,n = m
t LLol, RCn27,
for Cint ie0;iknliitt){ LCl a arr Lltil; i
)=

bile CiKnae i<n) arnlk+tl= (LlI <: REI) ?


ohile Ci<n)larr [ktt] = (L CinD,3
while C;<ndLarr LKe+] Ljtlii
void meYe Sort Cint arr[l, at, mt r)£
int me l+ Cr-2
at merge Sort Cart,l,
merqe Sat Carr, mtl, ),
me
Snt man C)E
Sot amCI= l2, 1l, 13,5, 6, 9
ht nsizeof Can)/si|eof Can Co7):
printf ("original array'i
Teachers Siçnature
Date

Expt. No. Page No.

pniotf C" " arr[i);

merge Sort Carr,0, n)


pritf C Sorted array :i";

Teacher's Signature
Output 5 6?
:12 )) 3
array
7 | | 12 13
:56
Soted ary
Date

Expe Ne 3 Page No

Ar of the xeniment
kinear Seavch

+ mclude <stdfo:h)
nt inear Search Giot ar L], iot n, nt )E
fox Cint i: O, in itt) E
f (arr Lil- e x) return is

re buro -

int n, Xi
pnin tf ("Enter the number of elements: "
Scanf C 1.d" nd;
int ar Cn];
priotf C" Enter the elemonty of the array : \n;
Scanf C id,&arr Ci);
protf C"Enter the eloment to serch : ;
scant ("d " , ;
int res e linear Search Carr, n, )s
printf C"Search result ihd n", res
return
Catput elemerts: 5
Enter the mumber of
Enter the elemont f Bhe aay
2 46 & 10
elementh to search :8
Enter the
Seareh result 8
Date

Expt. No. Page No.

Binary Seavch
Roqnam
nchude <[Link]
nt bínary Saarch Cint ar c], iat laft,it tiht int x)t
nt míd lat -left)2;
f 1Crtht
Carr Cmid] e reburn mid
f Carr nid]x) neburn binary Search Can, left ,mid -lx
reburn binazy Saxch an, mid 4l, nght,x)

lt man CoE

int ne Si|eof Carr)Lsi|eo f arr Lol);

ht result e binary Search Carr, 0, ncl, x)


pnatf C"Element Zd found at ndex hd \n"X, resul);
3else £
pnatf("Element Zd not found n,x
Tetum O;

Teacher's Signature
Outut mdez3
îndex3
Element 8 found at
Date

[Link]. 5 Page No.

din cf he Lxpuient
Matri Chain Multiplization

#nelude <[Link]
#lude <linith
ot gcm Ciot pLI, at n).
for Cint iel;niitt) mL)j]= Ds
for Cintle 2; <nilt)E

nt
3

snt plI- El,, 3, 43


iat n= s|eof Cp) si2eofCp Lo
priatf (Minisan number of multLplkatons i A\n' acmlpan

Teacher's Signature
Qitpdt
Minum unber of rultiplicatons
Date

Expt. No. Page No.

An cf the cxpesiernt
Longest Common Subseauence
#clude lstdið.h
incude <strmg: h
fot kmCcharX, char * , ot m, atnE

for Cint jz O;jj2=n jt

else &

3
3

nt manc
char xLl "AGGTA6
char YL]:"GXTXAYB:
strles CX;
nt n strlen CD;
retarn

Teacher's Signature
Outpct

You might also like