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

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 00:30, Thisisdifinite
Which of the following would you find on a network
Answers: 3
image
Computers and Technology, 23.06.2019 06:40, sardarp1irc5
What are the three uses of a screw?
Answers: 2
image
Computers and Technology, 23.06.2019 08:30, mai1261
Helen's credit card has an apr of 15.32% and a grace period of 17 days and helen pays her balance in the full every month. if her last billing cycle ended on september 26, 2009, and she made her payment on october 11, 2009, did she owe any interest on her last statement's balance?
Answers: 3
image
Computers and Technology, 23.06.2019 09:30, GEEKLIFE6598
After you present a proposal, the committee starts asking you questions, some beyond the strict focus of your proposal. they ask questions about implications in other fields and knowledge about other fields. you are asked to redo your proposal. what is most likely missing? breadth of material depth of material clarity of material details of material
Answers: 1
You know the right answer?
This is java programming:

objectives:

1. apply linear search algorithm

Questions in other subjects:

Konu
History, 03.02.2021 02:20