Let In be the set of n integers {1, 2,...,n} where n is some power of...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Let In be the set of n integers {1, 2,...,n} where n is some power of 2. Note that we can easily use an n-bit vector (i.e., an array of n bits) B[1..n] to maintain a subset S of In and perform the following three operations (where j is any integer in In) in constant time each: INSERT(): insert integer j into S. DELETE(): delete integer j from S. MEMBER(j): return true if je S, otherwise return false. Describe a data structure that supports all the above operations and also the following operation MAXIMUM: return the greatest integer in S such that: • The worst-case time complexity of operations INSERT(j), DELETE(j), and MAXIMUM is O(log n) each. The worst-case time complexity of MEMBER(j) is 0(1). • The data structure uses only O(n) bits of storage. Note that the binary representation of an integer i where 1 ≤ i ≤n takes (log n) bits. Assume that any pointer also takes (log n) bits. A solution that does not meet all the above requirements may not get any credit. HINT: Combine an n-bit vector with a complete binary tree, and avoid using pointers. a. Describe your data structure by drawing it for n = 8 and S = {1,2,6}, and by explaining this drawing briefly and clearly. Your drawing must be very clear. b. Explain how the operations INSERT(j), DELETE(j), and MAXIMUM are executed, and why they take O(log n) time in the worst-case. Be brief and precise. c. Explain how the operation MEMBER (j) is executed, and why it takes O(1) time in the worst-case. Be brief and precise. Let In be the set of n integers {1, 2,...,n} where n is some power of 2. Note that we can easily use an n-bit vector (i.e., an array of n bits) B[1..n] to maintain a subset S of In and perform the following three operations (where j is any integer in In) in constant time each: INSERT(): insert integer j into S. DELETE(): delete integer j from S. MEMBER(j): return true if je S, otherwise return false. Describe a data structure that supports all the above operations and also the following operation MAXIMUM: return the greatest integer in S such that: • The worst-case time complexity of operations INSERT(j), DELETE(j), and MAXIMUM is O(log n) each. The worst-case time complexity of MEMBER(j) is 0(1). • The data structure uses only O(n) bits of storage. Note that the binary representation of an integer i where 1 ≤ i ≤n takes (log n) bits. Assume that any pointer also takes (log n) bits. A solution that does not meet all the above requirements may not get any credit. HINT: Combine an n-bit vector with a complete binary tree, and avoid using pointers. a. Describe your data structure by drawing it for n = 8 and S = {1,2,6}, and by explaining this drawing briefly and clearly. Your drawing must be very clear. b. Explain how the operations INSERT(j), DELETE(j), and MAXIMUM are executed, and why they take O(log n) time in the worst-case. Be brief and precise. c. Explain how the operation MEMBER (j) is executed, and why it takes O(1) time in the worst-case. Be brief and precise.
Expert Answer:
Answer rating: 100% (QA)
The question provided involves designing a data structure that maintains a set S of integers from a finite set In 1 2 ldots n where n is a power of 2 ... View the full answer
Related Book For
Introduction to Algorithms
ISBN: 978-0262033848
3rd edition
Authors: Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest
Posted Date:
Students also viewed these programming questions
-
One class of permutations of the integers in the set S n = {0, 1, 2, . . . , 2 n 1} is defined by matrix multiplication over GF (2). For each integer x in S n , we view its binary representation as...
-
Managing Scope Changes Case Study Scope changes on a project can occur regardless of how well the project is planned or executed. Scope changes can be the result of something that was omitted during...
-
The Sooner Equipment Company has total assets of $100 million. Of this total, $40 million was financed with common equity and $60 million with debt (both long- and short-term). Its average accounts...
-
During a severe storm in Palm Beach, FL, on January 2, 1999, 31 inches of rain fell in a period of nine hours. Assuming that the raindrops hit the ground with a speed of 10 m/s, estimate the average...
-
Each row of the EyeColor.xlsx workbook contains a persons eye and hair color. You are interested in determining the relationship between eye and hair color. Choose the best result from Analyze Data...
-
A centrifugal radial water pump has the dimensions shown in Fig. P12.10. The volume rate of flow is \(0.25 \mathrm{ft}^{3} / \mathrm{s}\), and the absolute inlet velocity is directed radially...
-
(Comprehensive Income) Roxanne Carter Corporation reported the following for 2004: net sales $1,200,000; cost of goods sold $750,000; selling and administrative expenses $320,000; and an unrealized...
-
Describe some of the advantages & disadvantages of remote work arrangements. Give a personal example of someone you know or know of (including yourself if applicable) who works remotely, or who...
-
Harry Jamison, CPA, is planning to set up a business to prepare tax returns. Harry is the only person in the business, at least for now. Can he delegate any work? Should he? Explain.
-
Assume that US based Apple Inc. is a renowned company in Germany as well? The company is planning to issue bonds in international market to expand its operations in Germany? In your opinion should...
-
The following information is available for Dennison Company, which is entering bankruptcy proceedings. Net realizable values of Dennison's assets: Cash $5,000 Accounts receivable 12,000 Inventory...
-
(a)As an application of Monetary Policy, the financial regulator APRA introduced stricter lending standards for residential Home Mortgage Loans in March 2017.Briefly explain why this would shift the...
-
ABC trust is a schedule 1 bank with shareholder equity of $0.5billion. What is the max number of voting share of ABC Trust that a person or entity May own?
-
what is important of properly managing your finances, especially when you are already earning your own income?
-
An investment earned an average return of 20% per year. During the investment period, the real interest rate averaged 1.8% a year. To the nearest tenth of a percent, the implied average annual...
-
From the following information for BlueInks Corporation, compute the rate on return of assets. Net income after tax $30,548 Taxes $6,785 Interest expense $3,545 Total assets at beginning of the year...
-
Review Exhibit 11.4. Analyze each product on the graph according to the characteristics that influence the rate of adoption. For example, what can you conclude from the data about the relative...
-
Using Exercise 21.4-2, give a simple proof that operations on a disjoint-set forest with union by rank but without path compression run in O(m lg n) time. Exercise 21.4-2 Prove that every node has...
-
When RANDOMIZED-QUICKSORT runs, how many calls are made to the random number generator RANDOM in the worst case? How about in the best case? Give your answer in terms of -notation.
-
Give a multithreaded algorithm to multiply an n n matrix by an n-vector that achieves ( n 2 / lg n) parallelism while maintaining (n 2 ) work.
-
The percentage of heights between 156 centimeters and 168 centimeters
-
The population of unemployed adults has ages with mean m and standard deviations. Samples of unemployed adults are randomly selected so that there are exactly 100 in each sample. For each sample, the...
-
The percentage of heights between 148 centimeters and 170 centimeters
Study smarter with the SolutionInn App