Q1. In NIT Durgapur, there is a popular bakery named Wonder Cafe known for its delicious pastries and cakes. The bakery has a unique system in place to manage its orders. When customers arrive, they are given a token number and are told to wait in a special queue. The bakery has a stack of order slips, and when an order is ready, the cashier takes the top order slip from the stack, calls out the token number, and hands the order to the customer.
Lab Question:
You are a computer science student interning at the bakery, and your task is to simulate the bakery's order management system using a stack and a queue using (a)Array (b)Linked list. Design a program that accomplishes the following:
Implement a stack data structure to represent the order slips.
Implement a queue data structure to represent the customer queue.
Write a function to add orders to the stack when a customer places an order.
Write a function to remove orders from the stack and call out the corresponding token number.
Write a function to add customers to the queue when they arrive at the bakery.
Write a function to remove customers from the queue when their order is ready.
Q2: In the land of Algorithmia, there was a kingdom called Infixia, ruled by King Infix. The King's advisors often argued about the best way to write down their ideas so that they could be easily understood. One day, a traveler named Postfix arrived. He had a special way of speaking that made everything clearer. King Infix asked Postfix to teach his advisors this unique language.
Postfix agreed and showed the advisors how to write things in Postfix style. In Postfix, you put the operators after the numbers instead of between them. This made it easier to figure out complicated math problems. The advisors were amazed at how much easier their work became. They could now solve difficult problems without getting confused. Thanks to Postfix, King Infix's advisors could communicate better, and Infixia became a happy kingdom. Everyone in Infixia started using Postfix when they needed to solve math problems. And they all lived happily ever after. Prove the above philosophy.
Q3. In a busy part of West Bengal, among the lively streets of Kolkata, there was a small group of students. They all loved computers and wanted to solve a problem. They wanted to change normal numbers into binary numbers. The students, led by a young programmer named Raju, decided to use a stack to solve this problem. They knew that a stack could be a powerful tool for this task, as it could hold a sequence of numbers and easily reverse their order.