Limited access

Upgrade to access all content for this subject

Consider the following method.

// count the number of times element at position pos
// is greater than the element
// Pre-condition: pos will be a valid position in the array
// Pre-condition: nums contains at least one element
public static int countLessThan(int[] nums, int pos)
{
     int count=0;
     int selectNum = nums[pos];
     for (int number : nums)
     {
          if (number<selectNum)
              count++;
     }
     return count;
 }

If an array of non-repeating numbers sorted in descending order were passed to this method, what would it return?

A

nums.length – pos

B

nums[pos] – 1

C

nums.length – pos – 1

D

pos

E

pos – 1

Select an assignment template