Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

2. Download Queue Design a data structure for managing a download queue, such as the ones used in web browsers like Firefox and Chrome. These

image text in transcribed

2. Download Queue Design a data structure for managing a download queue, such as the ones used in web browsers like Firefox and Chrome. These queues work like a standard FIFO queue, but with two differences. First, browsers can download up to three files at a time, so the queue supports an operation to peek at the first three elements of the queue. Second, the queue prevents duplicate downloads. If an URL is already in the queue, it cannot be enqueued again. Design a dqueue (download queue) that supports the following operations. // Initialize an empty dqueue. DQUEUE_INIT() // Enqueue URL u at the end of the queue, unless u is already // present in the queue. DQUEUE_ADD(u) // Return the number of elements currently in the queue. DQUEUE_SIZE() // Return a list of the first three elements at the front of // the queue. If the queue currently contains fewer than three // elements, return the entire contents of the queue. DQUEUE_PEEK3() // Remove and return the element at the front of the queue. DQUEUE_POP() Design a data structure that implements all these operations. Write clear pseudocode that shows how each operation works. You should build upon the data structures we have already covered in class. Aim to have each operation run in O (1) time (worst-case, expected, or amortized)

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

Professional Microsoft SQL Server 2014 Integration Services

Authors: Brian Knight, Devin Knight

1st Edition

1118850904, 9781118850909

More Books

Students also viewed these Databases questions