Question: Questions 13 -14 require you to fill in the missing steps of the binary search algorithm. (6.25 points each) The binary search algorithm searches for

 Questions 13 -14 require you to fill in the missing stepsof the binary search algorithm. (6.25 points each) The binary search algorithm

Questions 13 -14 require you to fill in the missing steps of the binary search algorithm. (6.25 points each) The binary search algorithm searches for a number in an ordered list by continuously halving the list and only searching in the relevant half. Here's an example: Let's say we wanted to search for the number 10 in the following list [ 15 10 12 15 20 21 25]. We start by picking the middle number (15). 15 is larger than 10, so we repeat this process for the left half of the array: [1 5 10 12] This time, we pick 5 as our middle number. 10 is larger than 5, so we repeat this process for the right half of the array. 10 12] We pick 10 as our middle, and we have a match, so we return the position of 10 in the list. Step 1: function binary search(A: array of sorted random numbers, x: number being searched for) returns position of number in list if found, otherwise returns -1 Step 2: low = 1, high-length of A Step 3: while low

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!