Question: Below is the pseudocode for Binary Search for an array that needs to do the following but instead for a list function //Returns the index

Below is the pseudocode for Binary Search for an array

that needs to do the following but instead for a list function

//Returns the index where data is located in the List

//Calls the private helper function binarySearch to perform the search

//Pre: size != 0

//Pre: List is sorted (must test on a sorted list)

Pre: A[] is sorted in increasing order function binarySearch(A[1 ... n-1], value, low, high) if high < low return not found mid := low + (high-low)/2; //the midpoint formula if a[mid] := value return mid else if value < A[mid] //search the left half return binarySearch(A, value, low, mid-1) else //search the right half return binarySearch(A, value, mid+1, high) 

how do you write this function for a list function in c++ ?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!