Question: Repeat the amortised analysis of simple persistent queues on two lists ( in a single - use case ) , but using the banker's method.
Repeat the amortised analysis of simple persistent queues on two lists in a singleuse case but using the banker's method. What is the credit invariant?
Note that the reverse function on persistent lists is not defined in the notes: define it yourself! It should work in linear time.
FIFO and LIFO queues can be generalised to doubleended queues often known as deques which allow insertion and deletion from both ends of the queue. Generalise the persistent implementation of queues to fulfill an appropriate deque interface, and show that all operations can be performed in amortised constant time.
Hint: Consider what cases should have potential of no credits. How can you obtain them from cases of high potential?
The amortised complexity doesn't always need to be constant. Show that the unionfind data structure with arbitrary unions ie no optimisation of unions, can always pick left as a root, for instance but with path compression supports both union and find operations in amortised time Olog n
Hint: The analysis is slightly more complex this time. It is enough to consider find and union with the assumption that union is always called on roots of the respective sets since find has the same complexity in my analysis, both of these take logarithmic time. Banker's method was much more natural for me here, and all nodes except for roots and leaves contained some credits in my invariant.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
