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!
2
What do you call a structure whose data are nodes and linked together by oriented arcs?6
What is special about quick sort?6
What type of structure are the results of a recursive function stored in?9
What is recursion?5
What does the While loop do?2
What about the merge sort method?2
Given an array of 17 elements sorted in ascending order, what is the cost of accessing the element with index 10?