Question

In: Computer Science

The following questions relate to implementations of unbounded arrays. Read both parts before answering either of...

The following questions relate to implementations of unbounded arrays. Read both parts before answering either of them.
i. Describe an implementation of an unbounded array that has amortised cost of O(1) on both pushBack and popBack operations. In your description make sure you say how and when the necessary allocations and deallocation operations are performed.

ii. Use amortised analysis to demonstrate that pushBack and popBack can be performed on the structure you described in part (i) above at an amortised cost of O(1).

Solutions

Expert Solution

i.  Assume you have an array-based binary heap: a. with the contents: 1,4,7,8,9, 10,14, 12,15, 13, 17,12 Show the contents of a after each of the following two operations Show your working for each operation including the content of the list at its intermediate stages. You can assume a is large enough to contairn all the values inserted. insert 5 into a . deleteMin of a (b) The following questions relate to implementations of unbounded ar- rays. Read both parts before answering either of them. i. Describe an implementation of an unbounded array that has amor tised cost of O(1) on both pushBack and popBack operations. In your description make sure you say how and when the necessary allocations and deallocation operations are performed. ii. Use amortised analysis to demonstrate that pushBack and popBack can be performed on the structure you described in part (i) above at an amortised cost of O(1).

ii. Amortised Analysis is used for algorithms where an occasional operation is very slow, but most of the other operations are faster. In Amortized Analysis, we analyze a sequence of operations and guarantee a worst case average time which is lower than the worst case time of a particular expensive operation.
The example data structures whose operations are analyzed using Amortized Analysis are Hash Tables, Disjoint Sets and Splay Trees.

Let us consider an example of a simple hash table insertions. How do we decide table size? There is a trade-off between space and time, if we make hash-table size big, search time becomes fast, but space required becomes high.

The solution to this trade-off problem is to use Dynamic Table (or Arrays). The idea is to increase size of table whenever it becomes full. Following are the steps to follow when table becomes full.
1) Allocate memory for a larger table of size, typically twice the old table.
2) Copy the contents of old table to new table.
3) Free the old table.

If the table has space available, we simply insert new item in available space.


Related Solutions

Read case and get all the information before answering these questions. Please answer these questions specifically...
Read case and get all the information before answering these questions. Please answer these questions specifically what they are asking for with details 1. What specific type of wholesaler is Joe? 2. Evaluate Joe's marketing strategy for his current lumber business. Be and be sure to mention the specific components. 3. Contrast the components of the marketing strategy for the Arbor Products with Joe's current Hanratty lumber business. 4. What should Joe do now? Which option should he take? Be...
Stimulation (Please read the simulation before answering the questions . Please do not scan your answer,...
Stimulation (Please read the simulation before answering the questions . Please do not scan your answer, type please) Hey Ben. You’re getting an admission in the next 15 minutes coming from the outpatient clinic. BEN: Okay, what can you tell me about this client? JAN: Well, Susan Choi is 33 years old. (PATIENT) She’s been followed for depression over the past six months and is being admitted for acute mania. She is on administrative leave from her employment as a...
Read the following article to assess if this claim scientific by answering the questions that follow:...
Read the following article to assess if this claim scientific by answering the questions that follow: The term lunar effect refers to correlations between specific stages of the roughly 29.5-day lunar cycle and behavior in humans or other living things. In some cases these rhythms may depend on external cues, such as a greater or smaller amount of moonlight due to the moon's phases. A considerable number of studies have examined the effect on humans. By the late 1980s, there...
Read the following case study carefully and analyze it by answering the three Questions for Discussion.   ...
Read the following case study carefully and analyze it by answering the three Questions for Discussion.    Hot-Shot Pix is a global digital camera manufacturer headquartered in the U.S.  The company designs, manufacturers and sells various digital camera models at different price points through various channels.  Design is carried out at the company’s R&D labs located in England and the U.S.  The company manufactures cameras at four different locations:  one factory is located in Singapore and supplies the Asia-Pacific region; another factory is located in...
Please read the following restrictions before answering the question below: Restrictions: – Do not import any...
Please read the following restrictions before answering the question below: Restrictions: – Do not import any modules other than math and check. – You are always allowed to define your own helper/wrapper functions. Do not use Python constructs from later modules (e.g. dictionaries, zip, anything with sets or enumerators, list comprehension, commands continue or break). – Abstract list functions and recursion will not be allowed. Use only the functions and methods as follows: ∗ abs, len, max, min, sum, range...
My topic is the Automobile Industry Please read it carefully before answering Thankyou Continuing with the...
My topic is the Automobile Industry Please read it carefully before answering Thankyou Continuing with the business you have chosen, write an analysis of your business in three parts: i) Management & Leadership, ii) Organizational Structure, and iii) Operations Management, based on the material you have collected for the three topics. Each analysis should also refer back to the material you have learned in the course, and be between 250 and 500 words per topic, although you can go a...
PLEASE READ THIS CAREFULLY FIRST BEFORE ANSWERING!!!!!! A DOWN VOTE WILL BE GIVEN IF YOU JUST...
PLEASE READ THIS CAREFULLY FIRST BEFORE ANSWERING!!!!!! A DOWN VOTE WILL BE GIVEN IF YOU JUST PASTE AN ANSWER WITHOUT JUSTIFYING IT LIKE I'M ASKING FOR. I know this question is already on here but i have seen too many differing answers for a) and ultimately b) & c) so i am after justification for your answer that you provide. The main answers i have seen for a) are 35955.4 Kg/Hr and 44398.3 Kg/Hr dependant on which side they put...
Read the following article then answer questions below: “Before there was Paris Hilton, there was Consuelo...
Read the following article then answer questions below: “Before there was Paris Hilton, there was Consuelo Vanderbilt Balsan – a Gilded Age heiress and socialite, re-nowned for her beauty and wealth. Now Ms. Balsan’s onetime Hamptons home is slated to hit the market priced at $28 million with Tim Davis of the Corcoran Group. Located on Ox Pasture Road in Southampton, the shingle-style home was built around 1910 and is known as “Gardenside” or “Cara-Mia”. Ms. Balsan, the great-granddaughter of...
Simulation (Please read the scenario before answering the question. Also type your answer thanks) This is...
Simulation (Please read the scenario before answering the question. Also type your answer thanks) This is Becky, the nurse in the emergency Department. I am caring for Robert jones a 60-year-old African- American male. We admitted him at at 4:30   this morning. He reported increased shortness of breath and weakness.    His vitals were: blood pressure 80 over 62, R 30 pulse 164 and in a-fib. We gave him a 1000 milliliter bolus of sodium chloride to bring his blood pressure....
Please Read Carefully Before start answering this question. Please follow the instructions. This Question is from...
Please Read Carefully Before start answering this question. Please follow the instructions. This Question is from 'BSBFIM501 Manage budgets and financial plans' course. There are no parts missing for this Question; guaranteed!. This is the original Screenshot direct from the question. Therefore, there are nothing any further information can be provided. Thanks for your understanding and Cooperation. Please answer the following questions from the topics discussed for Prepare, implement, monitor and modify contingency plans: 1.a. Explain the process of preparing...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT