Search a sorted array of floating point numbers

Assignment Help Data Structure & Algorithms
Reference no: EM13707323

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.

Reference no: EM13707323

Questions Cloud

Explain at least three scenarios where he is wrong : Explain at least three scenarios where he is wrong, that is, where users other than a file's owner need some kind of allowed access privileges
How does the choice affect the user of the class : Write a partial C++ class definition not implementation that contains the public interface of the Date class described in Exercise R9.2.
Python programming to solve this problem : Write a statement that adds 1 to deansList and prints studentName to standard out if gpa exceeds 3.5.
Sum of the elements of the arithmetic progression : An arithmetic progression is a sequence of numbers in which the distance (or difference) between any two successive numbers if the same.
Search a sorted array of floating point numbers : You need to write a program which uses binary search to search a sorted array of floating point numbers - Create an array of doubles, using the following statement. Notice that the array is sorted.
Prepare a assembly program to initialize the led outputs : Write a main.asm file in PSoC designer. Make sure to have the subsequent in place - Initialize the LED outputs to 0's and Set the corresponding bit in INT_MSK0 to 1.
Prepare a function that generates a polynomial : Write a function genPoly(n) that generates a polynomial of length n (degree n-1), all of whose coefficients are 1.0.
Identify one reason indexes are useful : Describe what you would have to do if indexes weren't available in order to get the reason you initially stated and how the query optimizer generates and selects a query plan.
How long should a system be idle to benefit from hibernating : If reading or writing a cache-line of size 64 bytes to Flash requires 2.56 ?J and DRAM requires 0.5 nJ, and if idle power consumption for DRAM is 1.6 W (for 8 GB), how long should a system be idle to benefit from hibernating? Suppose a main memory..

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Implement an open hash table

In this programming assignment you will implement an open hash table and compare the performance of four hash functions using various prime table sizes.

  Use a search tree to find the solution

Explain how will use a search tree to find the solution.

  How to access virtualised applications through unicore

How to access virtualised applications through UNICORE

  Recursive tree algorithms

Write a recursive function to determine if a binary tree is a binary search tree.

  Determine the mean salary as well as the number of salaries

Determine the mean salary as well as the number of salaries.

  Currency conversion development

Currency Conversion Development

  Cloud computing assignment

WSDL service that receives a request for a stock market quote and returns the quote

  Design a gui and implement tic tac toe game in java

Design a GUI and implement Tic Tac Toe game in java

  Recursive implementation of euclids algorithm

Write a recursive implementation of Euclid's algorithm for finding the greatest common divisor (GCD) of two integers

  Data structures for a single algorithm

Data structures for a single algorithm

  Write the selection sort algorithm

Write the selection sort algorithm

  Design of sample and hold amplifiers for 100 msps by using n

The report is divided into four main parts. The introduction about sample, hold amplifier and design, bootstrap switch design followed by simulation results.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd