Question: Find the Logical Errors in given program. #include using namespace std; int Search(int L[],int size, int SearchKey) { int Result = -1; int Left =
Find the Logical Errors in given program.
#include
using namespace std;
int Search(int L[],int size, int SearchKey)
{
int Result = -1;
int Left = 0;
int Right = size - 1;
while (Left < Right)
{
int Mid = (Left + Right) / 2;
if (L[Mid] >SearchKey)
{
Right = Mid - 1;
}
else if (L[Mid] { Left = Mid + 1; } else { Result = Mid; } } return Result; }
Step by Step Solution
3.45 Rating (168 Votes )
There are 3 Steps involved in it
Changes made are highlighted by bold BinarySearchcp... View full answer
Get step-by-step solutions from verified subject matter experts
