Limited access

Upgrade to access all content for this subject

The following method performs a sequential search and returns the position of the first occurrence of key if it is found in array arr, or it returns -1 if it is not found:

public static int sequentialSearch(int[] arr, int key)
{
    int i = 0;
    while ( /*missing code*/ )
        i++;

    if (i == arr.length)
        return -1;
    else
        return i;
}

Which of the following should replace /*missing code*/?

A
i < arr.length
B
arr[i] == key
C
arr[i] == key && i < arr.length
D
arr[i] != key && i < arr.length
E
arr[i] != key || i < arr.length
Select an assignment template