Program produces 1000 integer ranging

Assignment Help JAVA Programming
Reference no: EM13163543

Part A.1 Do a selection sort according to the textbook using the random number generator. (You may copy the code from the textbook for the sorting algorithm). Your program asks the size of data and the range of data (smallest int and the largest int). Then you generate the number of data within the range of the data. You write the data into a file as shown below.

Program Sorting> Please enter the size of data: 1000
Program Sorting> Please enter the smallest value:1
Program Sorting> Please enter the largest value:10000
Program Sorting> Please enter the name of data file: data1

Then your program produces 1000 integer ranging from 1to 10000 in the array and then sort them in ascending order and then print the result into data.txt file. (You may list integers separated by space or new line)
Part A.2 Now you implement two search methods - linear search and binary search. You can use the sorted array from Part A.1 by continuing Part A Program to ask for keys to search. And you are required to read a data file provided by me as an input file. The name of input file should be given as an input argument to your program as below;

Java MySearch.class data1.txt

If argument is not given, then the program uses the default setting of the sorted array from the randomly produced data at A.1.

Program SortingAndSearch> Please enter the size of data: 1000
Program SortingAndSearch> Please enter the smallest value:1
Program SortingAndSearch> Please enter the largest value:10000
Program SortingAndSearch> Please enter the name of data file: data1
Program SortingAndSearch> Enter a key to search: 9999
Found at index 999 after 999 iterations of linear search
Found at index 999 after 9 iterations of binary search
Do you like to continue? Enter a key (negative int means you want to quit): 500
Found at index 49 after 49 iterations of linear search
Found at index 49 after 9 iterations of binary search
Do you like to continue? Enter a key (negative int means you want to quit): -1

Reference no: EM13163543

Imagine that you have been assigned

Imagine that you have been assigned to implement a sorting program. The goal is to make this program general purpose, in that you don't want to define in advance what recor

Sense a slightly negative attitude

While executing a project, you sense a slightly negative attitude in your team.Which type of document do you now need, among others, to better understand and then be able to i

Difference between sequential access and random access

What is the difference between sequential access and random access? What are BufferedInput/OutputStreams and why are they used? Write some Java code to illustrate how to crea

Change the implementation of the gettax method

Change the implementation of the getTax method in the TaxReturn class, by setting a variable rate1limit, depending on the marital status. Then have a single formula that com

Create a class named purchase

Create a class named Purchase. Each purchase contains an invoice number, amount of sale, and amount of sales tax. Include set methods for the invoice number and sale amount.

Implement the rules and logic for othello

In this project, you will implement the rules and logic for Othello. You are provided with the skeleton code containing the basic methods that you need to complete to launch

Write program that that displays jframe window with buttons

Write a program that that displays a JFrame window with 5 buttons. The buttons will be used to control the background color. The button's text will be randomly chosen from 5 c

Create a version of the game of nim that you can play

Create a version of the game of Nim that you can play against the computer. Use a JavaScript prompt() to prompt the user to select a pile and number of stones to remove from

Reviews

Write a Review

 
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