Question 10 (5 points) Your code is using a symbol table of type BinarySearchST . What...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Question 10 (5 points) Your code is using a symbol table of type BinarySearchST<Account, Transactions>. What methods must be defined in classes Account and/or Transactions in order for the symbol table to work correctly? The Account class must define the method public int compareTo(obect other) The Account class must define the method public int compareTo(Account other) and the Transactions class must define the method public boolean equals(Transactions other) The Account class must define the method public int compareTo(Account other) The Account class must define the method public int compareTo(Object other) and the Transactions class must define the method public boolean equals(Object other) Question 11 (5 points) Assume the contents of the keys array of a BinarySearchST are as depicted below. Trace the execution of a call to rank(55) by listing out the sequence of values that are assigned to the variable mid in the book's code (given below the array). List out the mid values with commas separating the values. For example, if you thought the values of mid took on the values 8 through 5 in decreasing order, you would write 8,7,6,5 0 1 2 3 4 5 6 7 8 9 4 12 33 38 50 53 61 72 7494 public int rank (Key key) { int loe, hi = n-1; while (lo <hi) { int mid 10 + (hilo) / 2; int cmp = key.compareTo(keys [mid]); if (cmp < 0) hi mid - 1; else if (cmp >e) lomid + 1; else return mid; return 10; } } Question 12 (5 points) Assume the contents of the keys array of a BinarySearchST are as depicted below. What value is returned by rank(100)? 0 1 2 3 4 5 6 7 8 9 4 12 33 38 50 53 61 72 7494 public int rank (Key key) { int loe, hi = n-1; while (lo <hi) { int midlo + (hilo) / 2; int cmp = key.compareTo(keys [mid]); (cmp) hi = mid = 1; if else if (cmp >e) lomid + 1; else return mid; } return lo; } -1 An exception is thrown 9 10 Question 8 (5 points) What is the order of growth of the worst case running time of the put operation for the book's BinarySearchST with n keys, when the key being inserted is already in the symbol table? constant O(1) linear O(n) logarithmic O(lg n) quadratic O(n²) Question 9 (5 points) What is the order of growth of the worst case running time of the put operation for the book's BinarySearchST with n keys, when the key being inserted is not already in the symbol table? quadratic O(n²) logarithmic O(Ign) constant O(1) linear O(n) Question 10 (5 points) Your code is using a symbol table of type BinarySearchST<Account, Transactions>. What methods must be defined in classes Account and/or Transactions in order for the symbol table to work correctly? The Account class must define the method public int compareTo(obect other) The Account class must define the method public int compareTo(Account other) and the Transactions class must define the method public boolean equals(Transactions other) The Account class must define the method public int compareTo(Account other) The Account class must define the method public int compareTo(Object other) and the Transactions class must define the method public boolean equals(Object other) Question 11 (5 points) Assume the contents of the keys array of a BinarySearchST are as depicted below. Trace the execution of a call to rank(55) by listing out the sequence of values that are assigned to the variable mid in the book's code (given below the array). List out the mid values with commas separating the values. For example, if you thought the values of mid took on the values 8 through 5 in decreasing order, you would write 8,7,6,5 0 1 2 3 4 5 6 7 8 9 4 12 33 38 50 53 61 72 7494 public int rank (Key key) { int loe, hi = n-1; while (lo <hi) { int mid 10 + (hilo) / 2; int cmp = key.compareTo(keys [mid]); if (cmp < 0) hi mid - 1; else if (cmp >e) lomid + 1; else return mid; return 10; } } Question 12 (5 points) Assume the contents of the keys array of a BinarySearchST are as depicted below. What value is returned by rank(100)? 0 1 2 3 4 5 6 7 8 9 4 12 33 38 50 53 61 72 7494 public int rank (Key key) { int loe, hi = n-1; while (lo <hi) { int midlo + (hilo) / 2; int cmp = key.compareTo(keys [mid]); (cmp) hi = mid = 1; if else if (cmp >e) lomid + 1; else return mid; } return lo; } -1 An exception is thrown 9 10 Question 8 (5 points) What is the order of growth of the worst case running time of the put operation for the book's BinarySearchST with n keys, when the key being inserted is already in the symbol table? constant O(1) linear O(n) logarithmic O(lg n) quadratic O(n²) Question 9 (5 points) What is the order of growth of the worst case running time of the put operation for the book's BinarySearchST with n keys, when the key being inserted is not already in the symbol table? quadratic O(n²) logarithmic O(Ign) constant O(1) linear O(n)
Expert Answer:
Answer rating: 100% (QA)
The detailed answer for the above question is provided below question 10 The correct answer is 1 The Account class must define the method public int compareToAccount other 2 The Transactions class mus... View the full answer
Related Book For
Smith and Roberson Business Law
ISBN: 978-0538473637
15th Edition
Authors: Richard A. Mann, Barry S. Roberts
Posted Date:
Students also viewed these programming questions
-
In this question you will be asked to reflect on a project you have been involved in or observed, in which a design evolved, or could have evolved, through applying a theory of user behaviour. You...
-
ttth Suppose that the sequence of bags {Bn | n N} is recursively enumerated by the computable function e(n, x) = fn(x), [7 marks] Hence prove that the set of all recursive bags cannot be recursively...
-
Jinny Buffett recently retired as a flight attendant and is interested in opening a fitness center and health spa exclusively for women in Grand Cayman, where she resides. After careful study, she is...
-
A financial manager has determined that the appropriate discount rate for a foreign project is 16 percent. However, that discount rate applies in the United States using dollars. What discount rate...
-
How would your idea be better than the existing competition?
-
Explain how the control variate technique is implemented.
-
The following are selected transactions that may affect stockholders' equity. 1. Recorded accrued interest earned on a note receivable. 2. Declared and distributed a stock split. 3. Declared a cash...
-
1. Tony stark is trying to talk pepper Potts into attending an event with him. Pepper does not want to attend because she feels that she and will be much older than most of the younger crowd...
-
Get It Right, CPAs, has been retained to review its client's corporate formation calculations for 20XX. Maria, Roger, and Novak created Grassroots Tennis, Inc. (GTI), which began operations on March...
-
How would you evaluate the overall performance of the drivers in this community?
-
Why is the Texas legislature dependent on the state comptroller of public accounts?
-
A 5.0-kg concrete block is lowered with a downward acceleration of 2.8 m/s by means of a rope. The force of the block on the rope is?
-
Discuss the key situational factors that can determine leadership effectiveness (according to Fiedler's contingency model, Hersey and Blanchard's situational leadership theory, and House's Path-Goal...
-
Commitment to which two factors precedes the acquisition of the quality of grit?
-
Consider the language L= {anb2nchin1} a) What class of the Chomsky hierarchy does L belong to? (Pick the smallest class that contains L) b) Prove that it belongs to the class you have chosen in part...
-
Design of this equation : 3^2-{cos(3)/tan3}^7 *
-
If the jobs displayed in Table 18.24 are processed using the earliestdue-date rule, what would be the lateness of job C? TABLE 18.24 Processing Times and Due Dates for Five Jobs Job C D E...
-
Two-year-old David Allen was bitten by Joseph Whiteheads dog while he was playing on the porch at the Allen residence. Allen suffered facial cuts, a severed muscle in his left eye, a hole in his left...
-
Anne, who was unemployed, registered with the Speedy Employment Agency. A contract was then made under which Anne, in consideration of such position as the Agency would obtain for her, agreed to pay...
-
Western Rivers Fly Fisher (Western) operates under license of the U.S. Forest Service as an outfitter, a corporation in the business of arranging fishing expeditions on the Green River, Utah. Michael...
-
In a recent study of how mice negotiate turns, the mice ran around a circular 90 turn on a track with a radius of 0.15 m. The maximum speed measured for a mouse (mass = 18.5 g) running around this...
-
It is well known that runners run more slowly around a curved track than a straight one. One hypothesis to explain this is that the total force from the track on a runners feet the magnitude of the...
-
You are driving your car through a roundabout that has a radius of 9.0 m. Your physics textbook is lying on the seat next to you. What is the fastest speed at which you can go around the curve...
Study smarter with the SolutionInn App