Solution to sequential search practice assignment

Complete the Sequential search practice problem before viewing the solution.

Review the sequential search practice assignment with AP CS Tutor Brandon Horn.

public static int sequentialSearch(int[] x, int key)
{
 for (int i = 0; i < x.length; i++)
  if (x[i] == key)
   return i;

 return -1;
}

Get AP CS Help

Leave a Reply