Question: java : here is a code that I have to implement. counting the occuence in an array /** * _Part 3: Implement this method._ *
java : here is a code that I have to implement. counting the occuence in an array
/** * _Part 3: Implement this method._ * * Counts the items in the ordered array list that are equal to the item at * the specified index. Be sure to take advantage of the fact that the list * is sorted here. You should not have to run through the entire list to * make this count. * * @param index an index in the range 0..(size-1) * @return the number of items in the list equal to the item returned by * get(index) */ public int countEquivalent ( int index ) { for (int i = 0; i < array.length; i++) { array[index] = array[i]; for (int j = 0; j < array.length; j++) { if (array[j]!=array[counter]) { return j; } } } return counter; } Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
