subject

This is java programming:

objectives:

1. apply linear search algorithm
2. apply select sort algorithm
3. apply array iteration skill

question:

write the following eight methods and write a main function to test these methods:

// return the index of the first occurrence of key in arr
// if key is not found in arra, return -1
public static int linearsearch(int arr[], int key)
// soert the arr from least to largest by using select sort algorithm
public stati void selectsort(int arr[])
// print out all array elements. 5 elements per line
public static void printarray(int arr[])
// assign each element in array with a random number
// between 1 and 100, inclusive
public static void initializearray(int arr[])
// find the range of all array elements
// the range is defined as the difference between the largest and smallest elements
public static int range(int arr[])
// find the largest element in array
public static int largst(int arr[])
// find the smallest element in array
public static int smallest(int arr[])
// find the average value of all elements in array
public static double average(int arr[])

sample pseudo code for main function

1. declare an int array of size 10
2. initialize the array by calling initializearray function
3. print out the array by calling printarray function
4. print out the largest and smallest value of the array by using system. out. prinln and calling largest and smalles functions
5. print out the range of the array
6. print out the average of the array elements
7. ask user to enter a search key
8. call the linearsearch function with array and key. based on result, print out appropriate message
9. call the selectsort function to sort the array.
10. print out array again to see the sorted array

use online resource: you may search on line to find the linear search and select sort algorithms.

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 07:50
In this lab, you complete a prewritten c++ program for a carpenter who creates personalized house signs. the program is supposed to compute the price of any sign a customer orders, based on the following facts: the charge for all signs is a minimum of $35.00. the first five letters or numbers are included in the minimum charge; there is a $4 charge for each additional character. if the sign is made of oak, add $20.00. no charge is added for pine. black or white characters are included in the minimum charge; there is an additional $15 charge for gold-leaf lettering. instructions ensure the file named housesign.cppis open in the code editor. you need to declare variables for the following, and initialize them where specified: a variable for the cost of the sign initialized to 0.00 (charge). a variable for the number of characters initialized to 8 (numchars). a variable for the color of the characters initialized to "gold" (color). a variable for the wood type initialized to "oak" (woodtype). write the rest of the program using assignment statements and ifstatements as appropriate. the output statements are written for you. execute the program by clicking the run button. your output should be: the charge for this sign is $82. this is the code, // housesign.cpp - this program calculates prices for custom made signs. #include #include using namespace std; int main() { // this is the work done in the housekeeping() function // declare and initialize variables here // charge for this sign // color of characters in sign // number of characters in sign // type of wood // this is the work done in the detailloop() function // write assignment and if statements here // this is the work done in the endofjob() function // output charge for this sign cout < < "the charge for this sign is $" < < charge < < endl; return(0); }
Answers: 1
question
Computers and Technology, 23.06.2019 07:00
1. you have a small business that is divided into 3 departments: accounting, sales, and administration. these departments have the following number of devices (computers, printers, etc.): accounting-31, sales-28, and administration-13. using a class c private network, subnet the network so that each department will have their own subnet. you must show/explain how you arrived at your conclusion and also show the following: all available device addresses for each department, the broadcast address for each department, and the network address for each department. also, determine how many "wasted" (not usable) addresses resulted from your subnetting (enumerate them).
Answers: 3
question
Computers and Technology, 23.06.2019 15:00
1. which of the following statements are true about routers and routing on the internet. choose two answers. a. protocols ensure that a single path between two computers is established before sending packets over it. b. routers are hierarchical and the "root" router is responsible for communicating to sub-routers the best paths for them to route internet traffic. c. a packet traveling between two computers on the internet may be rerouted many times along the way or even lost or "dropped". d. routers act independently and route packets as they see fit.
Answers: 2
question
Computers and Technology, 24.06.2019 00:00
Which tool could be used to display only rows containing presidents who served two terms
Answers: 3
You know the right answer?
This is java programming:

objectives:

1. apply linear search algorithm
Questions
question
Mathematics, 25.04.2021 23:00
question
Computers and Technology, 25.04.2021 23:00
question
French, 25.04.2021 23:00
Questions on the website: 13722361