Write a program that creates an array of 1000 random numbers

Assignment Help Computer Engineering
Reference no: EM132094014

Please answer following question with Java with extra credit:

Write a program that creates an array of 1000 random numbers in the range 1 - 5000. Then ask the user for a value between and 5000, and search the array until you either find the value or determine that the value is not in the array.

Print a message indicating whether or not the value was found, and how many numbers you had to look at before you found the value (or determined that it was not there).

Using either of the sorting algorithms presented in class, sort your array, then implement the following search algorithm to look for a value requested by the user:

1. Look at the middle value of the array; if the value is found, you're done. Otherwise, the value is either greater or less than this value

2. If the search didn't end in the step above, search the half of the array in which the value must be found (if the value is less than the middle value, search the half from the beginning up to midpoint-1; if the value is greater than the middle value, search from midpoint+1 up to length - 1) using the same method - that is, examine the middle value.

3. Continue the process of dividing the search area in half and examining the midpoint until either the value is found, or you are down to a search area of length 1 which does not contain the value.

4. As with the original search method, your program should report whether or not the value was found, and how many values you had to examine to determine the outcome.

Reference no: EM132094014

Questions Cloud

What facts and laws did the court rely on to decide : Brief 44 Liquormart, Inc. v. Rhode Island on p. 80-82. Use pages 22-23 for reference. In your brief, you should include the following information:
Which of the following is most likely to occur : Assume that the risk-free rate and expected inflation have not changed. Which of the following is most likely to occur
How many keys need to be exchanged in total : Consider a group of 30 people who wish to establish pair-wise secure communications using symmetric-key cryptography.
What are some potential problems of financial ratio analysis : What are some potential problems and limitations of financial ratio analysis
Write a program that creates an array of 1000 random numbers : Write a program that creates an array of 1000 random numbers in the range 1 - 5000. Then ask the user for a value between and 5000.
What are the purposes of control flow testing : What are the purposes of Control Flow testing and who needs to conduct Control Flow testing?
Describe such an attack : It is even easier to solve the Hill cipher if a chosen plaintext attack can be mounted. Describe such an attack.
Consider the various training and development formats : Consider the various training and development formats described in chapter 8. Which three do you think would be most effective for developing the skills
Are file descriptors of a parent inherited by child process : Is it allowed for a parent to terminate before one of its child processes has terminated? If so, does this affect the child processes in any way?

Reviews

Write a Review

Computer Engineering Questions & Answers

  Submit system design of data design and feasibility analysis

Submit system design of an introductory summary, a specification, a data design, a user interface design, a system architecture, and a feasibility analysis.

  Determine fractions of the original heat generated in tube

Helium flows in a thin-walled circular tube of 2.5 cm inside diameter. Down the center of the tube is inserted a 5 mm diameter circular electric heater.

  What technology characteristics should be evaluated

explain how Web services can be used to effectively integrate business applications and data. Search the Web for resources on current Web services such as XML, SOAP, UDDI and WSDL. Discuss how each is used, including examples from industry.

  Describe the advantages of this method

Early versions of Windows did not support true preemptive multitasking. Instead, designers of Windows provided something they called "cooperative multitasking".

  Cloud computing to the rescuewrite a two to three 4-5 page

cloud computing to the rescuewrite a two to three 4-5 page paper in which you1. describe the hardware software and

  Immediate determination of controllability

Under what conditions can inspection of the signal-flow graph of a system yield immediate determination of controllability?

  Discuss the significant impact on the business

As well same as e-commerce mobile technology also playing a lead role in online purchasing's. So, to the next change evolved in the business is by mobile.

  Create program to use vector and list to store ten integers

Create program to use vector and list to store 10 integers in order (from smallest to largest). You need to find proper location using vector or list function.

  How backup tool could be used during the preparation phase

Identify how the backup tool could be used during the preparation phase of the incident response and recovery process.

  Is it okay for you to borrow the software

Is it okay for you to borrow this software? Would it be okay if you uninstalled the application after you were finished using it? Would it be okay if the software was on the school's network and you could copy it from there?

  Create and test an html document that has half page of text

Create and test an HTML document that has at least a half page of text and a small box of text embedded on the left margin, with the main text flowing around.

  How can you sort array of country objects by increasing area

How can you sort an array of Country objects by increasing area? Can you use the Arrays.sort method to sort an array of String objects?

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