X912: Big O - 1

The code below finds the largest number in an int array. What is the growth rate, Big O(), of this method?

// Return the position of largest number
// in an array of integers
static int largest(int[] nums)
{
    int currlarge = 0; // Pos of largest
    for (int i = 1; i < nums.length; i++) {
        if (nums[currlarge] < nums[i]) {
            currlarge = i;    
        }
    }
    return currlarge;
}

Your Answer:

Select one answer:


Practice a different Java exercise

Feedback

Your feedback will appear here when you check your answer.