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, 23.06.2019 07:00
Why were most movies from the late 1890s until the early 1930s only filmed in black and white? there were only a few people who could afford the technology to produce color motion pictures back then. audiences did not want color motion pictures until later. the film used to make color motion pictures often overheated, which was a safety hazard, so it was generally not allowed. color films had to be hand-colored, frame by frame.
Answers: 3
question
Computers and Technology, 24.06.2019 10:20
Identify the publisher in this citation: carter,alan.a guide to entrepreneurship.new york: river’2008.print.
Answers: 3
question
Computers and Technology, 25.06.2019 00:00
To remove text from a specific location and keep it to use again, you should select
Answers: 1
question
Computers and Technology, 25.06.2019 07:30
Which behavior demonstrates teamwork
Answers: 1
You know the right answer?
This is java programming:

objectives:

1. apply linear search algorithm
Questions
question
Mathematics, 30.11.2021 02:40
question
Mathematics, 30.11.2021 02:40
Questions on the website: 13722363