Answered step by step
Verified Expert Solution
Question
1 Approved Answer
pseudocode !!!!!!!!!!!!! 2. Download Queue Design a data structure for managing a download queue, such as the ones used in web browsers like Firefox and
pseudocode !!!!!!!!!!!!!
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started