Skip to content

Assignment Submission #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Assignment1/Arpit-24/Bin_Search/bin10000inp.txt

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Assignment1/Arpit-24/Bin_Search/bin1000inp.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7 25 67 82 89 92 110 122 126 173 175 180 193 195 197 206 209 221 222 227 229 240 256 286 290 301 304 315 330 331 332 355 366 378 395 402 406 409 413 420 425 458 466 470 507 512 541 544 549 564 572 605 606 617 626 630 664 673 676 712 716 727 735 764 773 820 836 838 843 848 854 858 872 877 884 891 894 897 910 912 914 918 921 927 929 949 968 973 981 985 1000 1003 1007 1014 1022 1064 1073 1097 1102 1104 1119 1131 1132 1150 1164 1178 1190 1197 1204 1205 1208 1221 1224 1228 1233 1247 1267 1284 1291 1299 1306 1330 1332 1349 1354 1376 1383 1387 1403 1405 1420 1424 1426 1427 1463 1475 1478 1483 1488 1498 1508 1538 1552 1571 1576 1579 1597 1600 1602 1608 1610 1611 1614 1633 1649 1650 1653 1692 1711 1721 1733 1736 1748 1764 1780 1797 1812 1814 1846 1865 1866 1871 1873 1884 1885 1896 1898 1901 1903 1904 1907 1911 1923 1924 1940 1949 1954 1969 1973 1974 1985 1997 2015 2016 2024 2026 2033 2043 2075 2076 2085 2087 2091 2094 2098 2118 2126 2133 2149 2159 2179 2200 2217 2223 2225 2235 2269 2270 2272 2278 2336 2360 2367 2370 2377 2386 2405 2411 2413 2418 2424 2439 2461 2464 2481 2490 2503 2513 2532 2556 2578 2579 2582 2588 2591 2594 2595 2597 2601 2628 2631 2649 2668 2671 2680 2681 2683 2704 2711 2713 2714 2732 2734 2735 2754 2763 2765 2794 2795 2801 2809 2813 2838 2852 2861 2868 2869 2878 2879 2892 2901 2908 2916 2917 2926 2931 2932 2934 2951 2961 2973 2985 2986 2995 2999 3021 3028 3037 3038 3056 3078 3083 3088 3125 3132 3143 3146 3151 3155 3184 3189 3201 3215 3216 3226 3242 3255 3260 3266 3277 3281 3303 3309 3324 3347 3353 3355 3360 3363 3375 3376 3389 3393 3403 3409 3410 3419 3432 3451 3454 3455 3478 3493 3499 3511 3514 3520 3530 3552 3560 3565 3576 3584 3594 3596 3599 3603 3619 3621 3623 3639 3645 3654 3662 3670 3672 3694 3705 3715 3719 3721 3728 3745 3750 3769 3771 3789 3793 3794 3827 3831 3843 3845 3847 3865 3870 3906 3909 3918 3924 3943 3950 3952 3953 3959 3975 3976 3977 3989 4006 4008 4010 4020 4025 4034 4047 4053 4059 4065 4073 4083 4094 4107 4111 4143 4153 4175 4186 4190 4195 4203 4205 4207 4211 4213 4222 4243 4255 4263 4273 4274 4281 4283 4299 4307 4308 4314 4316 4337 4343 4357 4372 4394 4403 4435 4454 4472 4488 4492 4512 4523 4528 4531 4538 4548 4551 4552 4554 4555 4558 4570 4608 4616 4627 4641 4651 4652 4660 4680 4685 4693 4697 4717 4735 4737 4739 4748 4772 4794 4795 4816 4826 4830 4831 4846 4850 4854 4861 4873 4879 4888 4890 4894 4897 4898 4917 4918 4923 4931 4934 4937 4969 4974 4975 4979 5000 5003 5011 5013 5052 5053 5054 5067 5090 5096 5098 5111 5132 5144 5166 5167 5180 5193 5222 5229 5242 5246 5271 5310 5311 5327 5340 5375 5384 5388 5393 5418 5442 5447 5450 5452 5458 5465 5489 5494 5502 5513 5523 5532 5534 5539 5563 5567 5575 5588 5595 5619 5627 5632 5637 5660 5661 5664 5672 5688 5720 5721 5725 5735 5736 5741 5750 5752 5756 5769 5784 5789 5801 5807 5818 5819 5826 5858 5880 5903 5905 5913 5929 5945 5974 5981 5990 6002 6005 6013 6015 6016 6017 6029 6030 6036 6046 6058 6060 6081 6094 6096 6099 6106 6128 6129 6147 6176 6179 6216 6218 6223 6261 6276 6285 6286 6295 6332 6341 6347 6360 6362 6379 6386 6389 6394 6398 6402 6413 6420 6425 6429 6448 6450 6464 6472 6485 6486 6488 6507 6516 6529 6542 6548 6552 6553 6559 6573 6597 6598 6600 6601 6613 6631 6636 6648 6656 6660 6663 6664 6672 6705 6715 6719 6720 6743 6755 6758 6762 6789 6795 6801 6814 6816 6820 6826 6834 6842 6843 6845 6854 6856 6863 6873 6875 6904 6907 6916 6922 6929 6933 6935 6956 6968 6982 7011 7013 7048 7056 7057 7084 7113 7133 7166 7186 7189 7196 7201 7205 7206 7209 7228 7240 7244 7251 7274 7284 7293 7295 7296 7299 7300 7306 7318 7325 7342 7344 7354 7364 7366 7368 7393 7415 7423 7445 7454 7468 7471 7487 7503 7524 7525 7531 7543 7554 7555 7557 7560 7565 7580 7586 7616 7648 7652 7653 7655 7678 7679 7682 7693 7701 7704 7728 7730 7735 7754 7764 7785 7800 7810 7821 7856 7864 7884 7907 7908 7913 7931 7936 7946 7951 7956 7970 7974 7978 7995 7996 7998 8018 8027 8032 8040 8043 8057 8064 8070 8085 8104 8117 8119 8139 8154 8155 8170 8177 8182 8185 8198 8231 8232 8236 8244 8255 8260 8264 8269 8280 8282 8286 8296 8299 8308 8335 8336 8338 8348 8350 8353 8360 8365 8367 8380 8384 8389 8394 8408 8413 8414 8430 8435 8436 8447 8459 8462 8499 8507 8534 8537 8538 8551 8569 8594 8600 8609 8615 8619 8623 8627 8641 8647 8651 8652 8654 8655 8657 8659 8661 8662 8663 8667 8670 8681 8683 8685 8708 8720 8742 8761 8764 8780 8795 8804 8816 8822 8830 8869 8870 8881 8889 8900 8902 8913 8918 8982 8987 8998 8999 9000 9002 9010 9013 9021 9024 9030 9038 9050 9079 9089 9090 9093 9099 9118 9140 9158 9160 9165 9172 9211 9216 9223 9225 9253 9271 9277 9284 9292 9296 9297 9302 9308 9311 9312 9323 9331 9335 9345 9359 9366 9376 9377 9384 9393 9411 9444 9456 9466 9474 9481 9511 9523 9557 9570 9591 9593 9602 9615 9618 9621 9667 9685 9689 9699 9708 9722 9727 9735 9747 9750 9756 9775 9776 9780 9794 9803 9812 9815 9820 9840 9844 9846 9851 9862 9864 9869 9877 9897 9901 9918 9927 9939 9943 9953 9966 9978 9987 7 25 67 82 89 92 110 122 126 173 175 180 193 195 197 206 209 221 222 227 229 240 256 286 290 301 304 315 330 331 332 355 366 378 395 402 406 409 413 420 425 458 466 470 507 512 541 544 549 564 572 605 606 617 626 630 664 673 676 712 716 727 735 764 773 820 836 838 843 848 854 858 872 877 884 891 894 897 910 912 914 918 921 927 929 949 968 973 981 985 1000 1003 1007 1014 1022 1064 1073 1097 1102 1104 1119 1131 1132 1150 1164 1178 1190 1197 1204 1205 1208 1221 1224 1228 1233 1247 1267 1284 1291 1299 1306 1330 1332 1349 1354 1376 1383 1387 1403 1405 1420 1424 1426 1427 1463 1475 1478 1483 1488 1498 1508 1538 1552 1571 1576 1579 1597 1600 1602 1608 1610 1611 1614 1633 1649 1650 1653 1692 1711 1721 1733 1736 1748 1764 1780 1797 1812 1814 1846 1865 1866 1871 1873 1884 1885 1896 1898 1901 1903 1904 1907 1911 1923 1924 1940 1949 1954 1969 1973 1974 1985 1997 2015 2016 2024 2026 2033 2043 2075 2076 2085 2087 2091 2094 2098 2118 2126 2133 2149 2159 2179 2200 2217 2223 2225 2235 2269 2270 2272 2278 2336 2360 2367 2370 2377 2386 2405 2411 2413 2418 2424 2439 2461 2464 2481 2490 2503 2513 2532 2556 2578 2579 2582 2588 2591 2594 2595 2597 2601 2628 2631 2649 2668 2671 2680 2681 2683 2704 2711 2713 2714 2732 2734 2735 2754 2763 2765 2794 2795 2801 2809 2813 2838 2852 2861 2868 2869 2878 2879 2892 2901 2908 2916 2917 2926 2931 2932 2934 2951 2961 2973 2985 2986 2995 2999 3021 3028 3037 3038 3056 3078 3083 3088 3125 3132 3143 3146 3151 3155 3184 3189 3201 3215 3216 3226 3242 3255 3260 3266 3277 3281 3303 3309 3324 3347 3353 3355 3360 3363 3375 3376 3389 3393 3403 3409 3410 3419 3432 3451 3454 3455 3478 3493 3499 3511 3514 3520 3530 3552 3560 3565 3576 3584 3594 3596 3599 3603 3619 3621 3623 3639 3645 3654 3662 3670 3672 3694 3705 3715 3719 3721 3728 3745 3750 3769 3771 3789 3793 3794 3827 3831 3843 3845 3847 3865 3870 3906 3909 3918 3924 3943 3950 3952 3953 3959 3975 3976 3977 3989 4006 4008 4010 4020 4025 4034 4047 4053 4059 4065 4073 4083 4094 4107 4111 4143 4153 4175 4186 4190 4195 4203 4205 4207 4211 4213 4222 4243 4255 4263 4273 4274 4281 4283 4299 4307 4308 4314 4316 4337 4343 4357 4372 4394 4403 4435 4454 4472 4488 4492 4512 4523 4528 4531 4538 4548 4551 4552 4554 4555 4558 4570 4608 4616 4627 4641 4651 4652 4660 4680 4685 4693 4697 4717 4735 4737 4739 4748 4772 4794 4795 4816 4826 4830 4831 4846 4850 4854 4861 4873 4879 4888 4890 4894 4897 4898 4917 4918 4923 4931 4934 4937 4969 4974 4975 4979 5000 5003 5011 5013 5052 5053 5054 5067 5090 5096 5098 5111 5132 5144 5166 5167 5180 5193 5222 5229 5242 5246 5271 5310 5311 5327 5340 5375 5384 5388 5393 5418 5442 5447 5450 5452 5458 5465 5489 5494 5502 5513 5523 5532 5534 5539 5563 5567 5575 5588 5595 5619 5627 5632 5637 5660 5661 5664 5672 5688 5720 5721 5725 5735 5736 5741 5750 5752 5756 5769 5784 5789 5801 5807 5818 5819 5826 5858 5880 5903 5905 5913 5929 5945 5974 5981 5990 6002 6005 6013 6015 6016 6017 6029 6030 6036 6046 6058 6060 6081 6094 6096 6099 6106 6128 6129 6147 6176 6179 6216 6218 6223 6261 6276 6285 6286 6295 6332 6341 6347 6360 6362 6379 6386 6389 6394 6398 6402 6413 6420 6425 6429 6448 6450 6464 6472 6485 6486 6488 6507 6516 6529 6542 6548 6552 6553 6559 6573 6597 6598 6600 6601 6613 6631 6636 6648 6656 6660 6663 6664 6672 6705 6715 6719 6720 6743 6755 6758 6762 6789 6795 6801 6814 6816 6820 6826 6834 6842 6843 6845 6854 6856 6863 6873 6875 6904 6907 6916 6922 6929 6933 6935 6956 6968 6982 7011 7013 7048 7056 7057 7084 7113 7133 7166 7186 7189 7196 7201 7205 7206 7209 7228 7240 7244 7251 7274 7284 7293 7295 7296 7299 7300 7306 7318 7325 7342 7344 7354 7364 7366 7368 7393 7415 7423 7445 7454 7468 7471 7487 7503 7524 7525 7531 7543 7554 7555 7557 7560 7565 7580 7586 7616 7648 7652 7653 7655 7678 7679 7682 7693 7701 7704 7728 7730 7735 7754 7764 7785 7800 7810 7821 7856 7864 7884 7907 7908 7913 7931 7936 7946 7951 7956 7970 7974 7978 7995 7996 7998 8018 8027 8032 8040 8043 8057 8064 8070 8085 8104 8117 8119 8139 8154 8155 8170 8177 8182 8185 8198 8231 8232 8236 8244 8255 8260 8264 8269 8280 8282 8286 8296 8299 8308 8335 8336 8338 8348 8350 8353 8360 8365 8367 8380 8384 8389 8394 8408 8413 8414 8430 8435 8436 8447 8459 8462 8499 8507 8534 8537 8538 8551 8569 8594 8600 8609 8615 8619 8623 8627 8641 8647 8651 8652 8654 8655 8657 8659 8661 8662 8663 8667 8670 8681 8683 8685 8708 8720 8742 8761 8764 8780 8795 8804 8816 8822 8830 8869 8870 8881 8889 8900 8902 8913 8918 8982 8987 8998 8999 9000 9002 9010 9013 9021 9024 9030 9038 9050 9079 9089 9090 9093 9099 9118 9140 9158 9160 9165 9172 9211 9216 9223 9225 9253 9271 9277 9284 9292 9296 9297 9302 9308 9311 9312 9323 9331 9335 9345 9359 9366 9376 9377 9384 9393 9411 9444 9456 9466 9474 9481 9511 9523 9557 9570 9591 9593 9602 9615 9618 9621 9667 9685 9689 9699 9708 9722 9727 9735 9747 9750 9756 9775 9776 9780 9794 9803 9812 9815 9820 9840 9844 9846 9851 9862 9864 9869 9877 9897 9901 9918 9927 9939 9943 9953 9966 9978 9987
1 change: 1 addition & 0 deletions Assignment1/Arpit-24/Bin_Search/bin100inp.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
38 40 49 54 56 71 83 94 98 107 132 136 148 160 169 176 187 190 191 220 221 228 236 246 264 270 273 287 317 321 322 327 338 344 380 383 399 418 422 429 430 437 445 451 465 473 478 488 491 512 521 524 573 583 586 591 594 598 600 601 618 621 630 652 658 659 664 689 714 731 746 749 750 753 761 767 794 797 799 803 805 806 821 826 828 840 872 880 884 910 911 922 926 935 967 968 969 972 974 991 38 40 49 54 56 71 83 94 98 107 132 136 148 160 169 176 187 190 191 220 221 228 236 246 264 270 273 287 317 321 322 327 338 344 380 383 399 418 422 429 430 437 445 451 465 473 478 488 491 512 521 524 573 583 586 591 594 598 600 601 618 621 630 652 658 659 664 689 714 731 746 749 750 753 761 767 794 797 799 803 805 806 821 826 828 840 872 880 884 910 911 922 926 935 967 968 969 972 974 991
1 change: 1 addition & 0 deletions Assignment1/Arpit-24/Bin_Search/bin10inp.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
11 12 13 15 23 25 49 60 79 97 11 12 13 15 23 25 49 60 79 97
23 changes: 23 additions & 0 deletions Assignment1/Arpit-24/Bin_Search/binoutput.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Total time for 10 times loop run = 0.000002s

Avg. time for 10 times loop run = 0.000000s

Avg. No. of comparisons made : 2

Total time for 100 times loop run = 0.000018s

Avg. time for 100 times loop run = 0.000000s

Avg. No. of comparisons made : 5

Total time for 1000 times loop run = 0.000206s

Avg. time for 1000 times loop run = 0.000000s

Avg. No. of comparisons made : 8

Total time for 10000 times loop run = 0.002067s

Avg. time for 10000 times loop run = 0.000000s

Avg. No. of comparisons made : 12
44 changes: 44 additions & 0 deletions Assignment1/Arpit-24/Bin_Search/binsearch.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#include<stdio.h>
#include<time.h>

int cmp=0;
clock_t start_t, end_t;
double total_t, tot_time=0;

void binsearch(int list[], int key, int lo, int hi)
{
int mid;
start_t = clock();
while(lo<=hi)
{
mid=(hi+lo)/2;
if(++cmp&&list[mid]==key)
{
end_t = clock();
return;
}
else if(list[mid]>key)
hi=mid-1;
else
lo=mid+1;
}
end_t=clock();
}

int main()
{
int i, list[10000], key;
for(i=0;i<10000;i++)
scanf(" %d",&(list[i]));
for(i=0;i<10000;i++)
{
scanf(" %d",&key);
binsearch(list,key,0,9999);
total_t = (double)(end_t - start_t) / CLOCKS_PER_SEC;
tot_time+=total_t;
}
printf("Total time for 10000 times loop run = %lfs\n",tot_time);
printf("\nAvg. time for 10000 times loop run = %lfs\n",tot_time/10000);
printf("\nAvg. No. of comparisons made : %d",cmp/10000);
return 0;
}
Loading