Hi all,
how to search a element (value) in 2dimensional integer array using binary search...
Kindly suggest the solution..
Thanks,
sureshcools
Hi all,
how to search a element (value) in 2dimensional integer array using binary search...
Kindly suggest the solution..
Thanks,
sureshcools
The solution is to make an effort on your own...
This forum has a "homework policy"... we don't do your homework for you.
Even if this isn't homework nobody here is going to give you free code.
Write the thing as far as you can, then post the parts of the code giving you trouble along with specific questions.
Is the array at least sorted in some manner? If not that's a clue.
"Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
-Christopher Hitchens
First, hint given by hk_mp5kpdw.
Second, make a logic over the input number.
Third, move to that direction in array.
Fourth, loop from second to third again and again, until you find.
Finally, if found return or do whatever you want to else hopefully not found there.
In general there isn't a specific way to apply binary search to anything two dimensional, and depending on the specific circumstance, it may or may not be possible at all.
We'd need to know a lot more about the problem to work out 'if' and 'how' it may be possible to utilise binary search in your circumstance.
I guess one question back to you for a start with would be; how would you first sort this two dimensional data?
My homepage
Advice: Take only as directed - If symptoms persist, please see your debugger
Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"