Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please use c++ to solve the following data structure problem. Please attach an explanation describing how the program work and comments Thanks iPad? 16:12 ?10%
Please use c++ to solve the following data structure problem.
iPad? 16:12 ?10% ?+0 moodle.ncku.edu.tw Data Structure Homework2 1. Please use stack and queue to simulate the situation: National Cheng Kung university buy a bus, form Tainan train station to National Cheng Kung University. The bus can accumulate 4 people (total weight: 260kg), with only one door. The order of getting in/out bus is FIFO(first in first out). And there is a bus stop at Tainan train station, which can only accumulate 8 students for waiting. When bus arrive, the first four students gets in the bus in order. If the students overweight the weights that the bus can afford, the last student getting in the bus should get out the bus. And the next student can get in the bus. When the bus is gone, the following students can get in the waiting line at the bus stop. (Remember the upper bound of the amount of waiting students is 8) There are 20 students want to get in the bus stop in order Their weights are (70,67,75,55,51,40,87,65,58,86,66,43,57,76,68,61,60,63,39,74) Question: What is the order of the students arrived National Cheng Kung university? (Please show the sequence of the weights of the students) a. Please use Queue to stimulate the bus stop, and use Stack to stimulate the bus b. Print out the situation of getting in/out the bus and the situation of getting in/out the bus stop every time (The student who is overweight should get in the bus and then back to the weighting line.) Hint: Use a for loop to check. If there are less than 20 students arriving National Cheng Kung university, then keep going Please attach an explanation describing how the program work and comments
Thanks
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started