Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please explain why you chose your answer. 16) Consider the minimumposition metho

ID: 3835194 • Letter: P

Question

Please explain why you chose your answer.

16) Consider the minimumposition method from the selectionsorter class. Complete the code to write a maximumposition method that returns the index of the largest element in the range from index from to the end of the array static int minimum Position (int int from ate int min Pos from for (int from 1 i a length; i++) Pos retur mln. ate static int maximum Position (int, a, int from) int max Pos from for (int from 1 i a len i++) retur max Pos a if a [i] a Imax Posl max Pos b) if [i] a Imax Pos] max Pos if a [i] a Imax Posl i; max Pos i: a Imax Pos] max Pos

Explanation / Answer

16) We need to find index of Maximum Position :
So we will check if array is greater than max position till now, if yes then assign it to maxPos

a) if (arr[i] > arr[MaxPos] ) maxPos = i [Answer is (a)]

17)
We need a descending Order Merge, So we will check out of first and second, which array element is more, if case corresponds to first element is greater.
So, first[ iFirst ] > second[iSecond] [Answer is (c)]

18)
Since 15 is not present, Arrays.binSearch will return the neagtive index of where the element can be placed ,
15 is greater than 14 and less than 17 so 15 can be placed at that 5th position and not index , but the value will be negative to indicate that the element is not in the array.
So, -5 [Answer is (b)]

19)
Same as above we need to convert position to index , So we need to make it positive and decrement by 1
So, -1- index will make it possitive and decrease it by 1
So, bands.add(-1-index, "Beatles" ) [Answer is (d)]


20) CompareTo will return 0 is strings are equal, So We need to compare arr[mid ] and item

So, arr[mid].compareTo(item) [ Answer is (d) ]


Thanks, let me know if there is any concern/doubt