Queueing theory is the mathematical study of waiting in lines. In computing, queues are used to track requests that have been issued but not started. This is seen in applications like web services or online games in which many people request data from a server. The order of request processing we will consider is called First-In First-Out or FIFO. With a FIFO the processing works like lines at a grocery store, where each line (queue) is filled with customers (inbound requests) and is serviced by a cashier (a time- constrained processor). Customers arrive at the back of the line and the cashier services the customer at the front of the line. In other words, FIFO.

Simulating a time-constrained process is awkward. Thus, write a program uses a process that provides a simple way to verify that the FIFOs are working correctly. The program will simulate system storage using a data string that has been initialized with spaces. Queued requests will consist of a word and an offset. The program must write the requested word into the data string at the designated offset. The first character in the data string is at offset zero. All requests write into the same data string buffer. As an example of a request, for a data string of length 44 the request "35 KNOWN" would result in the following data string: see image.

Each request is added to a request queue and processed later. Some requests may overwrite portions of words previously written in the data string, so sequence is important. Each queue is a FIFO, but just like at the grocery store multiple queues can mean that requests (customers) are not always processed in the order they arrived. Input will be from a data file. The first line contains the length of the data string and the number of requests. The following lines are the actual requests. Each request has three parts: a queue number, an offset, and a word. There may be up to nine request queues (amazingly, numbered 1 through 9). The last line of input designates the order in which the requests are actually processed from the queues. On output, the program must process each request in the designated order and print the result string. Let the user input the filename from the keyboard. A queue data structure must be used, do not use the built in Java/C++ queue class. Refer to the sample output below.

Sample Run:

Enter the file name: queue.txt
IMAGINATION IS MORE IMPORTANT THAN KNOWLEDGE
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.