Medium
We have a table and we want to know if the value 42 is there. For this, we have the following code:
function findNum(array, 42, start, end)
{
If start > end then
{
display error;
}
Else
{
middle = (start+end)/2;
If array[middle] = 42
{
display ''we found 42'';
}
Else If array[middle]>42
{
findNum(array,42,start,middle-1);
}
Else
{
findNum(array,42, middle+1, end);
}
}
What must be checked for this binary search to work?
Edit
0
Community EvaluationsNo one has reviewed this question yet, be the first!
7
What is special about quick sort?5
What does the While loop do?2
What is the complexity of this algorithm?6
What type of structure are the results of a recursive function stored in?9
What is recursion?2
Given an array of 17 elements sorted in ascending order, what is the cost of accessing the element with index 10?2
What about the merge sort method?