Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a code to solve the above problem with the following conditions fulfilled: - You cannot hard code this part i.e your code should work

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Write a code to solve the above problem with the following conditions fulfilled: - You cannot hard code this part i.e your code should work for any number of winners. - Implement the two lanes as queues. - You are not allowed to use any other data structure except for the given two queues. - You are strictly not allowed to even use any variables. - You are only allowed to use the member functions of Queue you defined in part 2. (b) Shifting Stack marks =15 Suppose in the parallel universe, the earth is not struck by a pandemic and Sadly, the event management has a rough day today. The gifts to be given you decide to take a break from the semester's workload tochill at an out are stacked on the wrong table. They now have tostack the gifts on the amusement park. designated table in the same order. However, there isvery limited space and very limited labor available. The gifts are very heavy and can be lifted one You register for a lucky draw and oh boy, you win a prize! Life is good. at a time. Therefore, they approach you to give them a smart solution/algorithm since you managed to reverse the queuesmartly. FOR THE NEXT THREE PARTS, YOU CAN ONLY USE THE MEMBER FUNCTIONS DEFINED IN THE PART 1 AND PART 2 OF THIS ASSIGNMENT. (a) Reversing Queue marks =15 All the winners are asked to stand in a queue in the given positions. Unfortunately, the usher makes an error, and you all are now standing in the reversed order of the names' announcement for example, the order of the names' announcement is [A,B,C] with person A to be called first and the queue is lined up as [C,B,A] with person C at the front of the queue. You take the task of helping the winners reshuffling themselves tocorrect their position in the queue. However, the place is very crowded, andyou have to ensure that the positions are reversed in an algorithmic manner without causing any hassle. Luckily, there is an empty lane next toyour lane and you can use it in your algorithm but at the end, all the people should be standing in the reverse order in the same lane. Write a code to solve the above problem with the following conditions Here is what you have to do: fulfilled: 1. You will receive the customer ID of the customer whose priority score - You cannot hard code this part i.e., your code should work for any is to be calculated next and their respective characteristics. number of gifts. 2. You have to sort the customers according to their priority in descending - Implement the two tables as two stacks and a helper from the order. management as a variable. 3. Output the sorted waiting line and their priority scores - You are not allowed to use any other data structures except for the given two stacks and you cannot use more than one variable. Here is how you have to implement the above three steps: - You are only allowed to use member functions of Stack you defined in part 2. Step 1: Load all the weights assigned to each of these four factors in the (c) Sorting Stack marks =20 priority_coeff from the textfile named "ticket_priority.txt." Now load the The management started to feel that they need to increase customer customers, their IDs, and their respected characteristics from the text file satisfaction and enhance customer experience. They decided to prioritize named "waiting_line.txt" in the stack named customers. Before inserting customers based on some priority score while they are waiting at the ticket into the stack, calculate the priority score of each customer using a linear booth. They need to build an algorithm for a ticket booth that sorts model, with the weights of the model already loaded from customers based on several factors. "ticket_priority.txt." How the ticket booth operates: Step 2: The ticket booth asks each of its customers for the following information: Sort the customers in the customers stack using their priority values. 1) How long have they been waiting in line 2) If they have a premium membership to the park 3) If they are attending with their family You have two stacks: 4) If they are tourists 1. custoners (input stack) Your job is to calculate the priority scores of the customers based on their 2. terp_stack (local) answers to these questions and sort them. You have one variable: 1. temp (local) DO NOT CREATE ANY MORE VARIABLE OR DATA STRUCTURES IN THIS FUNCTION. YOU CANNOT USE ANYPREDEFINED LIBRARY OR HELPER FUNCTION Use the variable and data structures mentioned above to sortthe customers stack. You need to sort it according to priority coeff. Step 3: Step 3: Use the generate0utput 0 function to output the orders ofcustomers in a text file. Name the text file "output.txt". The output file must have the cutomer IDs and their ticket price. Run-down: Step 1 has already been done for you. Here is an example run-through for the above three steps: Step 1: PART 4: ANALYZING THE ALGORITHM marks =5 Do you think that sorting customers based on their priority score, as decided by the management, could introduce any bias? How would you add/remove any factors or change the weights to diminish it? Submit your responses as a PDF document along with the code files. Step 2: STACK: marks =10 Stack class contains LinkedList type object. You can only access memb functions of the LinkedList class for your implementation of stack (ar queue). Member functions: Write implementation for the following methods as described here. - Stack() : - Simple base constructor. - Stack (const Stack T& otherStack) : - Copies all elements from otherStack to the new stack. - void push (T item): - Pushes item at top of the stack. - T top (): - Returns top of the stack without deleting it. - T pop (): - Return and delete top of the stack. - int length () : - Returns count of the number of elements in the stack. - bool isEmpty () : - Return true if there is no element in the stack, false otherwise Member functions: Write implementation for the following methods as described here. - Queue () : - Simple base constructor. - Queue (const Queue T \& otherQueue): - Copy all elements of other Queue into the new queue. - void enqueue (T item): - Add item to the end of queue. - T front (): - Returns element at the front of queue without deleting it. - T dequeue () : - Returns and deletes element at front of queue. - int length(): - Returns count of number of elements in the queue. - bool isEmpty(): - Return true if there is no element in the queue, false otherwise

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions