Use the following code for the next questions: public boolean bins (int[] A, int st, int...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Use the following code for the next questions: public boolean bins (int[] A, int st, int low, int high) f if( low high ) ( return false; } int mid = (int) ((low + high)/2); if( A[mid] st ) return true; else if( A[mid] >st) return bins (A, st, low, mid-1); else return bins (A, st, mid+1, high); A) Trace until completion and show values of all variables for the following input: A 1, 3, 6, 8, 9, 12, 18, 22, 23, 25, 28, 32, 45, 57, 78, 87} st-63 low low-0 high A.length-1 high Mid A[mid] st Why did we stop (5 words or less please)? B) Trace until completion and show values of all variables for the following input: A 11.3, 6, 8, 9, 12, 18, 22, 23, 25, 28, 32, 45, 57, 78, 87) st-28 low low-0 high-A.length-1 high mid A[mid] st Why did we stop (5 words or less please)? Describe the runtime of the above code (5 words or less please): Use the following code for the next questions: public boolean bins (int[] A, int st, int low, int high) f if( low high ) ( return false; } int mid = (int) ((low + high)/2); if( A[mid] st ) return true; else if( A[mid] >st) return bins (A, st, low, mid-1); else return bins (A, st, mid+1, high); A) Trace until completion and show values of all variables for the following input: A 1, 3, 6, 8, 9, 12, 18, 22, 23, 25, 28, 32, 45, 57, 78, 87} st-63 low low-0 high A.length-1 high Mid A[mid] st Why did we stop (5 words or less please)? B) Trace until completion and show values of all variables for the following input: A 11.3, 6, 8, 9, 12, 18, 22, 23, 25, 28, 32, 45, 57, 78, 87) st-28 low low-0 high-A.length-1 high mid A[mid] st Why did we stop (5 words or less please)? Describe the runtime of the above code (5 words or less please):
Expert Answer:
Answer rating: 100% (QA)
A The table is given below low high Mid AMid st 0 15 7 22 63 8 ... View the full answer
Related Book For
Data Structures and Algorithms in Java
ISBN: 978-1118771334
6th edition
Authors: Michael T. Goodrich, Roberto Tamassia, Michael H. Goldwasser
Posted Date:
Students also viewed these programming questions
-
The following additional information is available for the Dr. Ivan and Irene Incisor family from Chapters 1-5. Ivan's grandfather died and left a portfolio of municipal bonds. In 2012, they pay Ivan...
-
The following information relates to the debt investments of Wildcat Inc. during a recent year: 1. On February 1, the company purchased Gibbons Corp. 10% bonds with a Face Value of $300,000 at 100...
-
Verify each identity by comparing the graph of the left side with the graph of the right side on a calculator. sin 4x(cos 2x - sin2x) sin 8x 2
-
The nozzle shown discharges a stream of water at a flow rate Q = 475 gal/min with a velocity v of magnitude 60 ft/s. The stream is split into two streams with equal flow rates by a wedge which is...
-
Julie Brown, the owner of Julies Party Sandwiches, has delegated management of the business to Stacie Wood, a friend. Brown drops by to meet customers and check up on cash receipts, but Wood buys the...
-
In the 1970s, Special Electric Company brokered the sale of crocidolite asbestos, which is the most toxic form of asbestos, to Johns- Manville Corporation. Special Electric never held possession of...
-
(Entries for Life Cycle of Bonds) On April 1, 2010, Seminole Company sold 15,000 of its 11%, 15-year, $1,000 face value bonds at 97. Interest payment dates are April 1 and October 1, and the company...
-
A seal dives below the ice in search of fish. Its path can be modelled by where d is the depth in decameters and t the time in minutes. Use the equation above to answer questions about the seal's...
-
Identify the errors in the following multiple-step income statement: Armortec Company Income Statement For the Year Ended December 31, 2015 Revenue from sales Sales Add: Sales returns and allowances...
-
PLANT Ltd acquired a property on 1 January 2018 for its investment potential at a cost of GHS200,000. On acquisition, the property was estimated to have useful life of 40 years. PLANT adopted a...
-
What kind of data is most important to companies to help them in the preparation of their budgets?
-
A company has the following revenue sources and expenditure commitments. Calculate the income and expenses that should be recognized for the year by item. Show your calculations. A $1,200 contract to...
-
An interesting demonstration of standing waves can be done by twirling one end of a flexible, corrugated hose that is open at both ends. The twirling motion causes air to be drawn through the hose,...
-
On January 15, D borrows $600,000 from S. S obtains a security interest on D's inventory. S fails to perfect its security interest. Cf. U.C.C. section 9-317(a)(1). On April 5, D files for bankruptcy....
-
Palencia Paints Corporation has a target capital structure of 40% debt and 60% common equity, with no preferred stock. Its before-tax cost of debt is 12%, and its marginal tax rate is 25%. The...
-
Discuss other two International University in two different countries that you wish to sell your products to and discuss the Macro environmental factors you will have to consider when entering those...
-
Suppose you won a financial literacy competition and are given FJS10000 to invest, with the condition that investment can be done either in, i) Invest in Unit trust of Fiji or Invest in Fijian...
-
Suppose you are given an array, A, containing 100 integers that were generated using the method r.nextInt(10), where r is an object of type java.util.Random. Let x denote the product of the integers...
-
Suppose that instead of having the node-search function f (d) = 1 in an orderd B-tree T, we have f (d) = logd. What does the asymptotic running time of performing a search in T now become?
-
How many edges are in the transitive closure of a graph that consists of a simple directed path of n vertices?
-
A German sports car is selling for 65,000. What is the dollar price in the United States for the German car if the exchange rate is 0.80 euro per dollar?
-
You are considering buying a bottle of wine. Suppose that the euro appreciates by 15% with respect to the U.S. dollar. Are you more or less likely to buy a bottle of Californian wine or French wine?
-
What is the exchange rate between dollars and Swiss francs if one dollar is convertible into 1/40 ounce of gold and one Swiss franc is convertible into 1/25 ounce of gold?
Study smarter with the SolutionInn App