Question: What single line of code would need to be changed if you wanted to do a Binary Search on a list sorted in descending order?
What single line of code would need to be changed if you wanted to do a Binary Search on a list sorted in descending order? How would you change it
Algorithm binarySearcha first, last, desiredItem
mid firstlast
if first last
return false
else if desiredItem equals amid
return true
else if desiredItem amid
return binarySearcha first, mid desiredItem
else desiredItem amid
return binarySearcha mid last, desiredItem
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
