Sale!

CSC 231 Project Seven An Array Festive solved

Original price was: $35.00.Current price is: $30.00. $25.50

Category:

Description

4.9/5 - (14 votes)

Purpose: The purpose for this project is to reinforce the knowledge learned in
Chapter 7.
Objectives:
1. Apply linear search algorithm
2. Apply select sort algorithm
3. Apply array iteration skill
Problem description:
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.
Submission:
Submit the YourProj07.java file via blackboard link. The due date will be announce
on blackboard