IITKESO207PA1Q2 - Queues
In this problem, you have to implement queues in C/C++. There are operations that you must implement.
1) Enqueue : Takes an element and adds it to the back of the queue.
2) Dequeue: Removes the first element in the queue.
3) Is_Empty : Returns true if the queue is empty, false otherwise.
Note: Using standard library implementation is NOT allowed and will be considered cheating. The penalty shall be applied as it given in the handout is for cheating cases.
First line contains t: the number of test cases. Each test case has lines.
The first line contains q, the number of queries. q lines follow.
Each query is has one or two space separated integers. The first is the opcode. 1 for Enqueue, 2 for Dequeue and 3 for Is_Empty.
If the opcode is 1, then there is another argument x that denotes the element to be enqueued. The opcodes 2 and 3 are not followed by any number.
The output is as follows:
For the Dequeue operation output the element that has been dequeued. If the queue is empty and a dequeue operation is asked, print "Empty" (without quotes).
For the Is_Empty operation output True/False.
For the Enqueue opearation, print the element enqueued.
1 <= t <= 10
1 <= q <= 1000000
1 <= x <= 10^9
The first line of the input says that there is only 1 test case.
The second line says there will be 7 queries.
The third line is 1 3 which means that we must enqueue 3 to the queue; the output is 3. Fourth line says that we enqueue 4 to the queue; the output is 4.
The fifth line asks for a dequeue operation and the output should be 3. The sixth line asks whether the queue is empty or not and the answer is False.