Project Seven An Array Festive Solution

$30.00 $24.00

Purpose: The purpose for this project is to reinforce the knowledge learned in Chapter 7. Objectives: Apply linear search algorithm Apply select sort algorithm 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…

5/5 – (2 votes)

You’ll get a: zip file solution

 

Description

5/5 – (2 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

  1. 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

  1. Initialize the array by calling initializeArray function

  1. Print out the array by calling printArray function

  2. Print out the largest and smallest value of the array by using System.out.prinln and calling largest and smalles functions

  1. Print out the range of the array

  1. Print out the average of the array elements

  2. Ask user to enter a search key

  1. Call the linearSearch function with array and key. Based on result, print out appropriate message

  1. Call the selectSort function to sort the array.

  1. 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

Project Seven An Array Festive Solution
$30.00 $24.00