×

# binary search base case

 0 if(low==high) { if(a[low]==key) { return low; } else {cout<<"THE value doesnt exist"; return nill; }  why is this base case not working for binary search asked 25 Aug '13, 20:11 31●9●13●17 accept rate: 0% 3★kuruma 17.7k●72●143●209 can u give ur whole code...or maybe the whole of ur binary search implementation!!! (25 Aug '13, 22:24) kunal3614★

 0 it might be a case that in while loop , the low index has passed (become greater) ,than 'high' index , therefore , i guess your if condition is not getting satisfied and hence , not giving desired output. answered 25 Aug '13, 20:22 386●6●8●18 accept rate: 0% can u please provide a simple test case ?? i mean what u are saying is the standard recursive definition but i am just curious to know why this case isnt working (25 Aug '13, 20:29)
 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×690
×166
×68

question asked: 25 Aug '13, 20:11

question was seen: 1,886 times

last updated: 25 Aug '13, 22:24