Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Q1. In an online game, a list of scores achieved by people who played the game is maintained. Each time a new person completes the

Q1. In an online game, a list of scores achieved by people who played the game is maintained. Each time a new person completes the game, the list gets extended by his/her score. To prevent the list from becoming prohibitively long, the bottom 25% scores are dropped from the list at certain points in time. It is required to design an ecient data structure S to maintain the scores and support the two operations Insert and Drop: (I) Show how to implement this data structure such that the amortized cost per any of the above two operations is O(1). Your implementation should also include a way to output the elements of S in O(|S|) time. (II) Using the aggregate method, show that the amortized cost per (Insert or Drop) operation is O(1); (III) Repeat (II) using the accounting method; (IV) Repeat (II) using the potential method; (V) Write a Python procedure DS(scores) implementing the above data structure. Your code should accept an input list containing the scores and a number of "-1's" marking the deletions. The program should output the final list.

For instance: DS[1; 2; 9; 5;-1; 8; 3; 1; 3; 2; 9;-1; 8] should return "[9; 5; 8; 3; 3; 9; 8]". Note: for an integer n, interpret image text in transcribed as roof image text in transcribedimage text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Securing SQL Server Protecting Your Database From Attackers

Authors: Denny Cherry

1st Edition

1597496251, 978-1597496254

More Books

Students also viewed these Databases questions

Question

Summarize the advantages of being a first mover.

Answered: 1 week ago

Question

4-6 Is there a digital divide? If so, why does it matter?

Answered: 1 week ago