Dsa
Queue
Warm-up
Windows Printer Queue
You are tasked with simulating a printer queue for a small office. The office can process print jobs in the order they are received (FIFO). You will receive input of print jobs in the form of requests. Each request is either 'enqueue <document_name>' or 'dequeue'. If a 'dequeue' request is made, you should print the name of the document that is currently being printed. If the queue is empty, print 'No documents to print.'
Input format:
- The first line contains an integer m (1 <= m <= 100) indicating the number of requests.
- The next m lines contain the requests as described above.
Output format:
- Print the responses to the dequeue operations or confirmations for enqueues.
Example:
Input:
4
enqueue Document1
enqueue Document2
dequeue
dequeue
Output:
Document added: Document1
Document added: Document2
Printing: Document1
Printing: Document2
Key concepts
queuedata structuresimulation
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now