Answered step by step
Verified Expert Solution
Question
1 Approved Answer
How many calls to the method recFind of the ArraySortList3 class are made when the find method of the class is passed each of the
How many calls to the method recFind of the ArraySortList3 class are made when the find method of the class is passed each of the following targets?
//---------------------------------------------------------------------------- // ArraySortedList3.java by Dale/Joyce/Weems Chapter 6 // // Implements the ListInterface using an array. It is kept in increasing order // as defined by the compareTo method of the added elements. Only Comparable // elements may be added to a list. // // Null elements are not permitted on a list. // // Two constructors are provided: one that creates a list of a default // original capacity, and one that allows the calling program to specify the // original capacity. //---------------------------------------------------------------------------- package ch06.lists; public class ArraySortedList3extends ArrayUnsortedList implements ListInterface { public ArraySortedList3() { super(); } public ArraySortedList3(int origCap) { super(origCap); } protected void recFind(Comparable target, int fromLocation, int toLocation) // Searches list between fromLocation and toLocation // for an occurrence of an element e such that // target.equals(e). If successful, sets instance variables // found to true and location to the array index of e. If // not successful, sets found to false. { if (fromLocation > toLocation) // Base case 1 found = false; else { int compareResult; location = (fromLocation + toLocation) / 2; compareResult = target.compareTo(list[location]); if (compareResult == 0) // Base case 2 found = true; else if (compareResult = add element } for (int index = numElements; index > location; index--) list[index] = list[index - 1]; list[location] = element; numElements++; } public boolean remove (T element) // Removes an element e from this list such that e.equals(element) // and returns true; if no such element exists, returns false. { find(element); if (found) { for (int i = location; i 45. How many calls to the recFi nd method of the Ar r aySort edList 3 class are made when the fi nd method of the class is passed each of the following targets? a. algorithm b. heap c. mega d. dynamic e. zebra
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started