Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started