tag:blogger.com,1999:blog-7953476913268941048.post2796636143063493286..comments2024-02-07T08:19:10.374-08:00Comments on Programming Tutorials: Binary Search Program in C, C++Unknownnoreply@blogger.comBlogger34125tag:blogger.com,1999:blog-7953476913268941048.post-28771663622058453472018-01-04T07:06:23.038-08:002018-01-04T07:06:23.038-08:00Does not work "at all" in descending ord...Does not work "at all" in descending order. Anonymoushttps://www.blogger.com/profile/12456272059763267667noreply@blogger.comtag:blogger.com,1999:blog-7953476913268941048.post-72513016474840912792017-09-22T14:48:00.209-07:002017-09-22T14:48:00.209-07:001- i didn't understand why you made while loop...1- i didn't understand why you made while loop low<=high ?<br />2- why you made equale in while loop?<br />3- what is the function exit(0)? what does it mean and what can i do by using it ? Anonymoushttps://www.blogger.com/profile/12127976945916752351noreply@blogger.comtag:blogger.com,1999:blog-7953476913268941048.post-75845399442104702782017-09-22T14:45:39.850-07:002017-09-22T14:45:39.850-07:001-i dont understand why you made while loop low<...1-i dont understand why you made while loop low<=end <br />2-why you made equale in while loop<br />3- what is the exit(0)? what does it make ?!Anonymoushttps://www.blogger.com/profile/12127976945916752351noreply@blogger.comtag:blogger.com,1999:blog-7953476913268941048.post-91676180346099955442017-07-29T12:18:49.518-07:002017-07-29T12:18:49.518-07:00In the case of beg>end the ouptput is not foun...In the case of beg>end the ouptput is not found number in list etc...but in same case is it possible to use the do...while loop or switch case for change the value of *end* for take some value in output..?<br />If is it possible plzz give code for it.Anonymoushttps://www.blogger.com/profile/06528850295607674671noreply@blogger.comtag:blogger.com,1999:blog-7953476913268941048.post-57636027216469639712017-03-19T01:30:33.556-07:002017-03-19T01:30:33.556-07:00nice solutionnice solutionAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-7953476913268941048.post-82471466028736617002017-02-18T08:24:02.960-08:002017-02-18T08:24:02.960-08:00#include
using namespace std;
main()
{
int beg,mi...#include<br />using namespace std;<br />main()<br />{<br /> int beg,mid,end,i,n,num;<br /> int a[10]={4,5,6,7,8,9,10,11,14,15};<br /> //initialize the beg & end value<br /> beg=0;<br /> end=10-1;<br /> cout<<"/n entr the value to search :";<br /> cin>>num;<br /> //run loop when bega[mid])<br /> {<br /> beg=mid+1;<br /> }<br /> else if(num<a[mid])<br /> {<br />Anonymoushttps://www.blogger.com/profile/17431248734130500923noreply@blogger.comtag:blogger.com,1999:blog-7953476913268941048.post-20700980061958780382017-02-18T08:01:10.503-08:002017-02-18T08:01:10.503-08:00Thanks for helping last cout<<"number n...Thanks for helping last cout<<"number not found" became before the close bracket in this way:<br />end=mid-1;<br />}<br />else<br />cout<<"number not found";<br />}<br />}<br />Binarey search in C++ Anonymoushttps://www.blogger.com/profile/17431248734130500923noreply@blogger.comtag:blogger.com,1999:blog-7953476913268941048.post-72261048914266220622017-01-20T22:27:52.865-08:002017-01-20T22:27:52.865-08:00write a program that input a number by user and se...write a program that input a number by user and search number given by user by using binary search .Anonymoushttps://www.blogger.com/profile/17117983755250145299noreply@blogger.comtag:blogger.com,1999:blog-7953476913268941048.post-32450339563335587182017-01-20T22:25:45.166-08:002017-01-20T22:25:45.166-08:00a program that input a ten number by user and se...a program that input a ten number by user and search a number given by user by using binary search.<br />Anonymoushttps://www.blogger.com/profile/17117983755250145299noreply@blogger.comtag:blogger.com,1999:blog-7953476913268941048.post-77351075629166404242017-01-19T16:06:45.544-08:002017-01-19T16:06:45.544-08:00what if we have two same numbers at different posi...what if we have two same numbers at different positions in an array and we want to find the position of both using BS??????Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-7953476913268941048.post-10592073500688136902016-11-24T07:32:56.513-08:002016-11-24T07:32:56.513-08:00Thanks man, it was great help!!Thanks man, it was great help!!mihirs16https://www.blogger.com/profile/13864306148137173239noreply@blogger.comtag:blogger.com,1999:blog-7953476913268941048.post-63667720864245033002016-09-18T01:10:30.654-07:002016-09-18T01:10:30.654-07:00but whybut whyAnonymoushttps://www.blogger.com/profile/11531508809558329050noreply@blogger.comtag:blogger.com,1999:blog-7953476913268941048.post-13283634119730105402016-09-12T05:22:20.233-07:002016-09-12T05:22:20.233-07:00this binary search code is wrong
you can't wr...this binary search code is wrong <br />you can't write mid=(low+high)/2 . It will create overflow.Assume that you have an array of size 2^32 and low = 2^32-2 and high = 2^32-1 so low +high will create overflow .<br />So the correct code will be mid = low+(high-low)/2;Amithttps://www.blogger.com/profile/14452762602078174029noreply@blogger.comtag:blogger.com,1999:blog-7953476913268941048.post-3654214644110588322016-05-15T21:17:39.534-07:002016-05-15T21:17:39.534-07:00What about dealing with string arrays or char arra...What about dealing with string arrays or char arrays??The REAL Xavierhttps://www.blogger.com/profile/05731867816264240948noreply@blogger.comtag:blogger.com,1999:blog-7953476913268941048.post-78023884824811671402016-04-15T04:42:13.881-07:002016-04-15T04:42:13.881-07:00Use stdlib.h for exit 0 function
Use stdlib.h for exit 0 function<br />Anonymoushttps://www.blogger.com/profile/02334777852507303982noreply@blogger.comtag:blogger.com,1999:blog-7953476913268941048.post-25101424309907949232016-04-15T04:41:52.717-07:002016-04-15T04:41:52.717-07:00Use stdlib.h for exit 0 function
Use stdlib.h for exit 0 function<br />Anonymoushttps://www.blogger.com/profile/02334777852507303982noreply@blogger.comtag:blogger.com,1999:blog-7953476913268941048.post-54621931101975555992016-03-04T07:48:18.486-08:002016-03-04T07:48:18.486-08:00If num > arr[mid] then set beg flag to mid + 1 ...If num > arr[mid] then set beg flag to mid + 1 as number is greater than mid so you will search the item in second halve.Programming Tutorialhttps://www.blogger.com/profile/06415123639935228733noreply@blogger.comtag:blogger.com,1999:blog-7953476913268941048.post-55064757995910184982016-03-03T00:52:58.486-08:002016-03-03T00:52:58.486-08:00No, choice of variable is our choice, we can choos...No, choice of variable is our choice, we can choose any name of the variableAnonymoushttps://www.blogger.com/profile/11221707312118104295noreply@blogger.comtag:blogger.com,1999:blog-7953476913268941048.post-25589712987533331092016-03-03T00:45:48.533-08:002016-03-03T00:45:48.533-08:00I couldn't figure out the logic of what happen...I couldn't figure out the logic of what happens if num>Arr[mid] pls help me!!Anonymoushttps://www.blogger.com/profile/11221707312118104295noreply@blogger.comtag:blogger.com,1999:blog-7953476913268941048.post-75504392934106720012016-03-03T00:44:32.369-08:002016-03-03T00:44:32.369-08:00I couldn't figure out the last few lines of th...I couldn't figure out the last few lines of the code, pls help meAnonymoushttps://www.blogger.com/profile/11221707312118104295noreply@blogger.comtag:blogger.com,1999:blog-7953476913268941048.post-84050069846107054092016-02-07T20:48:08.324-08:002016-02-07T20:48:08.324-08:00is 'loc' of the input value not required t...is 'loc' of the input value not required to find the position ?<br />Anonymoushttps://www.blogger.com/profile/08954088074673540915noreply@blogger.comtag:blogger.com,1999:blog-7953476913268941048.post-19274386225768208032016-02-07T02:41:17.960-08:002016-02-07T02:41:17.960-08:00What's the input you are entering.What's the input you are entering.Programming Tutorialhttps://www.blogger.com/profile/06415123639935228733noreply@blogger.comtag:blogger.com,1999:blog-7953476913268941048.post-72215187189780422722016-02-07T00:43:06.662-08:002016-02-07T00:43:06.662-08:00what is the expected output ?what is the expected output ?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-7953476913268941048.post-90674406886733440722016-02-03T15:37:10.379-08:002016-02-03T15:37:10.379-08:00What kind of help do you need in Binary Search pro...What kind of help do you need in Binary Search program.Programming Tutorialhttps://www.blogger.com/profile/06415123639935228733noreply@blogger.comtag:blogger.com,1999:blog-7953476913268941048.post-43352440256920436122016-02-03T15:36:32.216-08:002016-02-03T15:36:32.216-08:00Worst case of binary search occur when element you...Worst case of binary search occur when element you are searching is not present in array or list.Programming Tutorialhttps://www.blogger.com/profile/06415123639935228733noreply@blogger.com