Answered step by step
Verified Expert Solution
Link Copied!

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.
Please attach an explanation describing how the program work and comments
Thanks
image text in transcribed
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

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

Recommended Textbook for

Transactions On Large Scale Data And Knowledge Centered Systems Xxxviii Special Issue On Database And Expert Systems Applications Lncs 11250

Authors: Abdelkader Hameurlain ,Roland Wagner ,Sven Hartmann ,Hui Ma

1st Edition

3662583836, 978-3662583838

More Books

Students also viewed these Databases questions