From af7f80613d6a3025b375918dbb24a590bdec31ae Mon Sep 17 00:00:00 2001 From: Rajashree Parhi Date: Tue, 9 Oct 2018 19:35:23 +0530 Subject: [PATCH] Added the code in C language --- .../longest_common_subsequence/C/a.out | Bin 0 -> 12800 bytes search/interpolation_search/C/a.out | Bin 0 -> 8448 bytes search/interpolation_search/C/interpolation.c | 75 ++++++++++++++++++ 3 files changed, 75 insertions(+) create mode 100755 dynamic_programing/longest_common_subsequence/C/a.out create mode 100755 search/interpolation_search/C/a.out create mode 100644 search/interpolation_search/C/interpolation.c diff --git a/dynamic_programing/longest_common_subsequence/C/a.out b/dynamic_programing/longest_common_subsequence/C/a.out new file mode 100755 index 0000000000000000000000000000000000000000..4ea01e94ee08969954bcc2d836ee2e2a3fa01965 GIT binary patch literal 12800 zcmeHNdvH|M89%$5g@9qRKq7CsAXLz1c^L?5G#e7Q=>()0lv3cb+1(`DCYy908W1Z_R;-T>TI?iHE%kw^3ftdz?)f%%FB@^D z{i~C+bMJS)-}gA*`Odj#@8j&KtzYSMI0P4$xLFYA9c3a_O3-tys(@693NZ%f8DhF1 zwE~Hm@+y-+YL-FenrWfJU7%!F;WPm|ov!qla)dyiT<@Twb=S_?fEiiUqBa#--OUXbqLMMxx2ivd)U7WlOL3 z#oK+0WxvTk>8@I{UbaNztz1cY33$RtepBgB#!tE9z0K&1 zl8InTASOCuk!Yex#1paBa8wvZurpvZMWTV$$o8;^2LsV2fMjOG6Mja6_Q6H4MwyED%?`TtSKwV#qA6JvQP}8IWaGpCw-#WQzF|C{?L>LDKXDN^h%|F(29 z|03-5-it0hbx!Z?zeRT((NA1VOol_ha#%zThx50yvJPq@xj^r#oJ6(t6i<%FI(y2B*hC56by4h$}k;wQvS!DKnqyVqu*-qr6&y^=cG z{}5U+S#r?r_Cme*i2`Tw(>;*RzL?3J-Ei49rVX``OqRf%Y-2EWBz3ZXIT|=ynr&A$ zI+rlVp6B{x|GF!Gcooue zwEN;DSlBvWpr@WeXIx}jATP` z7^G=;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pg+ena2kP4c z4PUEU_^p~l;;!Y}Z{4&?{*047jt_AHdNrh{3fWS;KSO(G2@3`4AFpU#G_T@)L}dGZ z1h9$z^doLZ?(g-H0{Q$tKBv*oIH+g|)IV9#5@y3e}AW7J_A4Y3Lt0yFaIkezQjk;Kzds=PD=P6LEv0Oq3gOT;)H!Ms=mY`;&97WeR^t1;Y5#m9~K69#eX17@YRMsBqT9 z_LTj@cuEMziR2$r{&1|YTw2a3URUzJE1vtI-2c}I-#5Ju-%2}cz#Rq`GVI`DZW7PdMm{jI{U5^uN7lu=EEoFEEZSz z;N%A8@bhyizkb$yy(az4p05d|&%Xzf#n+!?W%l~H1l(6yWqcO~5tj ztMu!~5}&;u8iChio$&ax)l%S#%dG#qB+gnz`oJ7`TH*n*T>Vg-RVI(kq5lkUipRTd zPXO17%{jG~fL~X!Oz=6%f;S0=C*G&(=R&*(oW^ZPjayt9ybM~8b=ct97tbnvewXFk z^#X9x_m11AO8<)Lugops`-;Rlx*}bQiKFw|9T!=Dk$rj3C}Dn^fj9d|_7_sY-(m~$v5MfEEY!zV?dUPCnIE_YC}m=1myq(Q4RK|!J6^?_@?y< zrL>&MV0=KW$blG~FlU?EOVhUCI$DSfCZdRm7D5nXD}vY-bYU-UyZ^XG_W*2J=WVhP z`K_n3QuQO?iyd>>+Z5;AuoAMUab4Bai* zp7T_u{GS5H&w5NBhCSU?nCE{_EOq(4|yTboNFn!8n?*yU(;&|B& z^Gtu>vFG1srf+*LgxoIsd&XnW_jRV;^xoV5XO%tAALkiNf5Z(b%5gLNQ;)s(f5$df zRMgx4OCEc^Uoc(cS@7QWUxz*A>O4%GkMjSKUVY}7{uZ`%E_;5zIH4XuSPv?)FwgXl zKxwMEeZJT5|GoUbF0W6v<9VdKp1R2P{C;tqfXTbH*VQw>~WMMb^#{{$bPu7>~s literal 0 HcmV?d00001 diff --git a/search/interpolation_search/C/interpolation.c b/search/interpolation_search/C/interpolation.c new file mode 100644 index 0000000..2265655 --- /dev/null +++ b/search/interpolation_search/C/interpolation.c @@ -0,0 +1,75 @@ +#include + +#define MAX 200 + +int interpolation_search(int a[], int bottom, int top, int item) + +{ + + int mid; + + while (bottom <= top) { + + mid = bottom + (top - bottom) * ((item - a[bottom]) / (a[top] - a[bottom])); + + if (item == a[mid]) + + return mid + 1; + + if (item < a[mid]) + + top = mid - 1; + + else + + bottom = mid + 1; + + } + + return -1; + +} + +/* End of interpolation_search() */ + + + +/* The main() begins */ + +int main() + +{ + + int arr[MAX]; + + int i, num; + + int item, pos; + + printf("\nEnter total elements (num< %d) : ", MAX); + + scanf("%d", &num); + + printf("Enter %d Elements in ascending order: ", num); + + for (i = 0; i < num; i++) + + scanf("%d", &arr[i]); + + printf("\nSearch For : "); + + scanf("%d", &item); + + pos = interpolation_search(&arr[0], 0, num - 1, item); + + if (pos == -1) + + printf("\nElement %d not found\n", item); + + else + + printf("\nElement %d found at position %d\n", item, pos); + + return 0; + +} \ No newline at end of file