You need to write a program which uses binary search to


Program: You need to write a program which uses binary search to search a sorted array of floating point numbers.

Part 1: - Create an array of doubles, using the following statement. Notice that the array is sorted.

Part 2: - array: .double 4.5 8.1 9.9 12.0 20.2 45.5 53.35 67.75 75.4 99.9 115.0 121.5

Part 3: Create a loop which will prompt the user to enter a double and then perform binary search to check whether the double is in your array and print a message.

Continue prompting and searching until the user enters a negative number.

Part 4:- For binary search, use the iterative algorithm shown below. This searches your array for the input value key, using your array, and initializing imin to 0 (subscript of first element), imax to 11 (subscript of last element),

 found = false; // continue searching while A[imin] to A[imax] is not empty while (imax >= imin && !found) { // calculate the midpoint for roughly equal partition int imid = (imin + imax) / 2; if(A[imid] == key) { // key found at index imid print message: key " found in location" imid; found = true; } // determine which subarray to search else if (A[imid] < key) // change min index to search upper subarray imin = imid + 1; else // change max index to search lower subarray imax = imid - 1; } // key was not found print message: key " not found";

You have to implement a binary search to search a sorted array of floating point numbers.

Request for Solution File

Ask an Expert for Answer!!
Data Structure & Algorithms: You need to write a program which uses binary search to
Reference No:- TGS0960589

Expected delivery within 24 Hours