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% (1 review)
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
-
a. What are some of the key differences between traditional and digital marketing, and how might these differences impact the small business owner's decision? (5 Marks) b. What are the various social...
-
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...
-
In Exercises, find the indefinite integral and check the result by differentiation. 3/3 - 4x(-8x) dx
-
What are the characteristics of, and who benefits from, a well-run exchange?
-
The manager of Snyders Garden Center must make the annual purchasing plans for rakes, gloves, and other gardening items. One of the items the company stocks is Fast- Grow, a liquid fertilizer. The...
-
The Stay Healthy Insurance Co . is trying to sell you an investment policy that will pay you and your heirs $ 3 0 , 0 0 0 per year forever. Suppose the required return is 6 % , at what price would...
-
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...
-
Use Figure 21 to find all angles between 0 and 2 satisfying the given condition. sec t = 2 Sn 3 4 5 4 2 3 4 3 k/e 2 3 2 4 7 3 4 3 62' 4) -0 (1,0) 11z 6
-
After graduating from college, you are hired to work in a factory overseas as an industrial psychologist. The workers put together IPODs. The boss wants to know the best pay schedule to get the...
-
The following events occurred for Favata Company: a. Received $14,000 cash from owners and issued stock to them. b. Borrowed $11,000 cash from a bank and signed a note due later this year. c. Bought...
-
You are the administrator for several web servers that make up the NLB cluster. They run on servers with Windows Server 2008 R2. Explain the best way to upgrade the NLB cluster to Windows Server 2012...
-
A major concept involved in auditing is evidence regarding managements assertionsor more simply, audit evidence. Audit evidence consists of the underlying accounting data and additional information...
-
How does the motif of mirrors and reflections serve to explore themes of identity and self-perception in Gothic literature, and how do these themes manifest in the psychological evolution of key...
-
Dessert Delite Company produces frozen microwavable desserts. The following accounts appeared in the ledger as of December 31. Additional information: a. Accounts payable is used only for...
-
A copper rod of length L =18.0 in is to be twisted by torques T (see figure) until the angle of rotation between the ends of the rod is 3.08. (a) If the allowable shear strain in the copper is 0.0006...
-
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...
-
Pettijohn Inc. The balance sheet and income statement shown below are for Pettijohn Inc. Note that the firm has no amortization charges, it does not lease any assets, none of its debt must be retired...
-
hat is the purpose of the trial balance in accounting? 2. What is the difference between cash basis accounting and accrual basis accounting? 3. How are depreciation and amortization different in...
-
Firm D is considering investing $ 4 0 0 , 0 0 0 cash in a three - year project with the following cash flows. Use Appendix A and Appendix B . Year 0 Year 1 Year 2 Investment / return of investment $...
Study smarter with the SolutionInn App