Question: Consider the following algorithm that implements linear search: public static boolean find ( int target , int [ ] pool ) { for(int i =

Consider the following algorithm that implements linear search:

public static boolean find ( int target , int [ ] pool ) { for(int i = 0; i < pool.length; i++)

}

if(pool[i] == target) return true ;

return false ;

If you were asked to analyze the performance of this algorithm, would it be useful to write a growth function that counts the number of times the return false statement will execute? That is, use the number of returns as the cost metric. Explain.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!