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