Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Search Array: The linear search approach compares the key element key sequentially with each element in the array. It continues to do so until the
Search Array: The linear search approach compares the key element key sequentially with each element in the array. It continues to do so until the key matches an element in the array or the array is exhausted without a match being found. If a match is made, the linear search returns the index of the element in the array that matches the key. If no match is found, the search returns -1. public static int linear Search(int[] list, int key) Write the following method that takes an array of integers and a key value. The method search for key if the array contains the key , methods must return the index of key otherwise it must return -1. Write a test program that do the following; 1. create an array of integer with the size 100 2. fill array with randomly generated number between 0-50 3. prompt user to enter number between 0 -50, and search the array for that number by using
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started