Write a program that prompts the user to enter the number of elements and the numbers...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a program that prompts the user to enter the number of elements and the numbers themselves to be placed in an integer array that holds a maximum of 50 elements. The program should then prompt the user for an integer which will be searched for in the array using a binary search. Make sure to include the fol- lowing steps along the way: i) A sort routine must be called before the binary search. You may use either the selection sort or the bubble sort. However, the sort must be imple- mented in its own function and not in main. ii) Next include a function called by main to implement the binary search. The ordered array produced by the sort should be passed to the search routine which returns the location in the sorted array of the sought value, or -1 if the value is not in the array. iii) Add a value returning function that computes the mean of your data set. Recall that the mean is the sum of the data values divided by the number of pieces of data. Your program should output the size of the array entered, the array as entered by the user, the sorted array, the integer being searched for, the location of that integer in the sorted array (or an appropriate message if it is not in the array), and the mean of the data set. Write a program that prompts the user to enter the number of elements and the numbers themselves to be placed in an integer array that holds a maximum of 50 elements. The program should then prompt the user for an integer which will be searched for in the array using a binary search. Make sure to include the fol- lowing steps along the way: i) A sort routine must be called before the binary search. You may use either the selection sort or the bubble sort. However, the sort must be imple- mented in its own function and not in main. ii) Next include a function called by main to implement the binary search. The ordered array produced by the sort should be passed to the search routine which returns the location in the sorted array of the sought value, or -1 if the value is not in the array. iii) Add a value returning function that computes the mean of your data set. Recall that the mean is the sum of the data values divided by the number of pieces of data. Your program should output the size of the array entered, the array as entered by the user, the sorted array, the integer being searched for, the location of that integer in the sorted array (or an appropriate message if it is not in the array), and the mean of the data set.
Expert Answer:
Answer rating: 100% (QA)
Sure Heres an example program in Python that meets the requirements you specified python def sortarr... View the full answer
Related Book For
Introduction To Java Programming And Data Structures Comprehensive Version
ISBN: 9780136520238
12th Edition
Authors: Y. Daniel Liang
Posted Date:
Students also viewed these algorithms questions
-
can someone solve this Modern workstations typically have memory systems that incorporate two or three levels of caching. Explain why they are designed like this. [4 marks] In order to investigate...
-
You have been provided with the description of a programming language, J, intended for scripting applications. Its syntax is similar to a cut-down version of Java in that it consists of function...
-
An inverted pyramidal tank has an equilateral triangular base measuring 3 ft. on a side and an altitude of 7 ft. DSMIT adi a. How many gallons of water can the tank hold? b. What will be the wetted...
-
Inspire Inc. has a 49% ownership stake in Baldwin Industries. Crown Company has a 24% stake in Baldwin Industries. Inspire Inc. has been offered $19.6 Million for 80% of its stake. If Crown Company...
-
Have you considered a career as an enterprise architect? What bundle of courses would you put together to design a major or a track in enterprise architecture? Break into small groups with your...
-
You have made an appointment with a new potential customer. As you prepare for the presentation you realize this person has never purchased this kind of product before. What do you do?
-
1. Do you agree that the entrepreneurs company is not sellable? 2. Are there any other options for the entrepreneur besides selling his business? 3. What would you recommend the entrepreneur do? Why?
-
On July 1, 2023, Howe Corporation issues 2,000,000 shares of its common stock for all of Essex Corporation's outstanding shares and Essex is dissolved. The fair value of Howe's common stock on that...
-
3. Here is the declaration of a linked list node and head pointer. struct Node }; Node nextPtr_; int value_; Node headPtr; Write the code for the following function that searches the list for a node...
-
1. Corporate debt has been expanding very dramatically in the last three decades. What has been the impact on interest coverage, particularly since 1977? (LO16-1) 2. What are some specific features...
-
U Stores Ltd. had the following account balances at December 31, 2021: Deferred revenue $8,96 What is total net sales for this company?0 Travel and entertainment expense 11,340 Cash received from...
-
Assume that the shell-creating process has 8,000 units in BWIP, 20% complete. During the year, 50,000 units were completed and transferred out. (Note: All 50,000 units were sold; no other units were...
-
What is the outlook for climate change based on what you read in the articles? What makes you form your opinion? Why has it been suggested that eating less meat will help with climate change, based...
-
What is Health Care? What are the different types of health care services? What are the main competencies that are needed for health care professionals?
-
Choose any podcast related to macroeconomics, then choose a specific current episode of that podcast that is different from your earlier choices. Your reference will be the name of, and link to, your...
-
Solve for the equilibria of the following discrete-time dynamical systems Pr pt+1 = Pr+2.0(I-Pr)
-
You can approximate e using the following summation: Write a program that displays the e value for i = 1, 2, , and 20. Format the number to display 16 digits after the decimal point. (Hint: Because...
-
Modify Listing 31.12, TabPaneDemo.java, to add a pane of radio buttons for specifying the tab placement of the tab pane, as shown in Figure 31.57b and c. Data from Listing 31.12, Listing 31.12...
-
Write a program that creates an ArrayList and adds a Loan object, a Date object, a string, and a Circle object to the list, and use a loop to display all the elements in the list by invoking the...
-
Consider the multiple linear regression model fit to the baseball data in Problem 3.41. Problem 3.41 Consider the 2016 major league baseball data in Table B.22. While team ERA was useful in...
-
Consider the simple linear regression model fit to the rental price data from Problem 2.36. Data From Problem 2.36 Table B.24 contains data on median family home rental price and other data for 51 US...
-
Consider the multiple linear regression model fit to the rental price data in Problem 3.42. Problem 3.42 Table B.24 contains data on median family home rental price and other data for 51 US cities....
Study smarter with the SolutionInn App