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

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

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