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

1 Expert Approved Answer
Step: 1 Unlock

Changes made are highlighted by bold BinarySearchcp... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!