Implement a binary search and the quadratic binary search of Section 9.1. Run your implementations over a
Question:
Implement a binary search and the quadratic binary search of Section 9.1.
Run your implementations over a large range of problem sizes, timing the results for each algorithm. Graph and compare these timing results.
Transcribed Image Text:
The location of a particular key within the key range is translated into the expected position for the corresponding record in the table, and this position is checked first. As with binary search, the value of the key found eliminates all records either above or below that position. The actual value of the key found can then be used to compute a new position within the remaining range of the table. The next check is made based on the new computation. This proceeds until either the desired record is found, or the table is narrowed until no records are left. A variation on dictionary search is known as Quadratic Binary Search (QBS), and we will analyze this in detail because its analysis is easier than that of the general dictionary search. QBS will first compute p and then examine L[[pn]]. If K L[[pn]] we will step forward by n until we reach a value in L that is greater than K. We are now within n positions of K. Assume (for now) that it takes a constant number of comparisons to bracket K within a sublist of size n. We then take this sublist and repeat the process recursively. What is the cost for QBS? Note that = n/2, and we will be repeatedly taking square roots of the current sublist size until we find the item we are looking for. Because n = 2logn and we can cut log n in half only log log n times, the cost is (log log n) if the number of probes on jump search is constant. The number of comparisons needed is i=1 iP (need exactly i probes)
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 100% (QA)
Youve provided a question which requests the implementation of a standard binary search and a ...View the full answer
Answered By
PALASH JHANWAR
I am a Chartered Accountant with AIR 45 in CA - IPCC. I am a Merit Holder ( B.Com ). The following is my educational details.
PLEASE ACCESS MY RESUME FROM THE FOLLOWING LINK: https://drive.google.com/file/d/1hYR1uch-ff6MRC_cDB07K6VqY9kQ3SFL/view?usp=sharing
3.80+
3+ Reviews
10+ Question Solved
Related Book For
Practical Introduction To Data Structures And Algorithm Analysis Java Edition
ISBN: 9780136609117
1st Edition
Authors: Clifford A. Shaffer
Question Posted:
Students also viewed these Computer science questions
-
implement a binary search tree to allow duplicates have each node store a data structure of items that are considered duplicates (using the first item in this structure) to control branching
-
ABC Business is also using special glue for assembly the computer parts together. The glue costs are around $765 each month. Please indicate which of the following cost categories the glue cost...
-
Which of these groups has the higher priority? b) -COH or CNH2 a) -CH3 or -CH,CH3 c) -CH;CH,CH3 d) -CH-CH CH3 or -C=N or -CH;CH,CH,CH3 CH3 e) -CHCH3 or
-
Consider a Carnot-cycle heat pump with R-22 as the working fluid. Heat is rejected from the R-22 at 40C, during which process the R-22 changes from saturated vapor to saturated liquid. The...
-
Using Fig. 5.75 , design a problem to help other students better understand summing amplifiers. Calculate the output voltage due to the summing amplifier shown in Fig. 5.75. V, R1 V2 R2 (+-) Vo V3 R3...
-
ZeeZee's Construction Company has the opportunity to select one of four projects (A, B, C, or D) or choose the null (do-nothing) alternative. Each project requires a single initial investment and has...
-
Machinery purchased for $52,000 by Carver Co. in 2008 was originally estimated to have a life of 8 years with a salvage value of $4,000 at the end of that time. Depreciation has been entered for 5...
-
Question-1: For the Euclidean space of RK define a new metric as follows: K d(x,y)=xy; |P i=1 1/p for p1
-
Implement the three self-organizing list heuristics count, move-to-front, and transpose. Compare the cost for running the three heuristics on various input data. The cost metric should be the total...
-
Consider the following permutation for the numbers 1 to 6: 2, 4, 6, 1, 3, 5. Analyze what will happen if this permutation is used by an implementation of pseudo-random probing on a hash table of size...
-
Two samples contain different radioactive isotopes. Is it possible for these samples to have the same activity? (a) Yes, if they have the same number of nuclei but different half-lives. (b) Yes, if...
-
The viscosity of SAE 10 W30 oil is = 0.100 N s/m. Determine its kinematic viscosity. The specific gravity is So = 0.92. Express the answer in Sl and FPS units. *1-28. If the kinematic viscosity of...
-
When a nonlinear (or unstable) load is connected to a three phase motor system, the harmonic currents in the neutral wire will become very high? Why or why not ?
-
Barry and Gary have an Uncle Larry. When Barry was born, Uncle Larry gave him 100 shares of stock in GTX Corp, the price of the stock was $10.00/share, and it has returned 8% annually. Uncle Larry...
-
Assume that a 20.0 volt energy source is in a circuit that has a resistance of 4.00 ohms. Determine the power consumption in watts.
-
The following exchange rates are simultaneously quoted in New York and Frankfurt 1.4355 $/ (New York) 0.6825 /$ (Frankfurt) (a) Is there any arbitrage opportunity with these quotations? (b) How would...
-
You have $100,000 to invest in either Stock D, stock F, or a risk-free asset. You must invest all of your money. Your goal is to create a portfolio that has an expected return of 12 percent. If D has...
-
The population of Detroit, Michigan, decreased from 1,027,974 in 1990 to 688,701 in 2013 (Source: U.S. Census Bureau). Find the average rate of change in the population of Detroit, Michigan, over the...
-
Is an oil pipeline a simplex system, a half-duplex system, a full-duplex system, or none of the above? What about a river or a walkie-talkie-style communication?
-
The cost of a fast microprocessor has dropped to the point where it is now possible to put one in each modem. How does that affect the handling of telephone line errors? Does it negate the need for...
-
A modem constellation diagram similar to Fig. 2-23 has data points at the following coordinates: (1, 1), (1, 1), (1, 1), and (1, 1). How many bps can a modem with these parameters achieve at 1200...
-
1. ERP systems need ongoing support to ensure that the system does what it is supposed to do. Identify and describe the support structures needed for stabilization and postproduction support. 2. The...
-
1. How might changes in the level of dividends cause conflicts of interest between holders of different kinds of the companys securities? 2. How does the discount on the price of shares sold via a...
-
The cost of staying at a campground is $60 for the first day or less, and $40 for each additional day or part of a day. Sketch the graph of this situation for the first four days.
Study smarter with the SolutionInn App