Write this C program using a push-pop and top function

Assignment Help Other Subject
Reference no: EM13254267

Before bridges were common, ferries were used to transport cars across rivers. River ferries, unlike their larger cousins, run on a guide line and are powered by the river's current. Cars drive onto the ferry from one end, the ferry crosses the river, and the cars exit from the other end of the ferry.

There is an l-meter-long ferry that crosses the river. A car may arrive at either river bank to be transported by the ferry to the opposite bank. The ferry travels continuously back and forth between the banks so long as it is carrying a car or there is at least one car waiting at either bank. Whenever the ferry arrives at one of the banks, it unloads its cargo and loads up cars that are waiting to cross as long as they fit on its deck. The cars are loaded in the order of their arrival; ferry's deck accommodates only one lane of cars. The ferry is initially on the left bank where it broke and it took quite some time to fix it. In the meantime, lines of cars formed on both banks that await to cross the river.

The first line of input contains c, the number of test cases. Each test case begins with l, m. m lines follow describing the cars that arrive in this order to be transported. Each line gives the length of a car (in centimeters), and the bank at which the car arrives ("left" or "right").

For each test case, output one line giving the number of times the ferry has to cross the river in order to serve all waiting cars.

Write this C program using a Push, Pop, and Top function.

Reference no: EM13254267

Questions Cloud

Discuss the techniques available to research marketers : Discuss the techniques available to research marketers during data colction.
What are the attitude components : What are the attitude components? How do they shape marketing decisions?
Pressure in the pulmonary artery : Why it would be bad if the pressure in the pulmonary artery was 25 mmHg and right ventricular systolic pressure was 20 mmHg?
Speed racer takes his squeeze : Speed Racer takes his squeeze, Trixie, on a wild spin through town in his hot racing car, the March 5. Paying more attention to Trixie than the road, Speed carelessly runs a stop sign and narrowly avoids hitting Chim-Chim, a pedestrian who is crossin..
Write this C program using a push-pop and top function : Before bridges were common, ferries were used to transport cars across rivers. River ferries, unlike their larger cousins, run on a guide line and are powered by the river's current. Cars drive onto the ferry from one end, the ferry crosses the river..
Bringing in external consultants trainers : Determine two advantages and disadvantages of bringing in external consultants  as trainers to improve existing training methods within an organization.
State the balanced chemical equation : predict whether a reaction will occur in each of the following. if so write the balanced chemical equation as well as the net ionic equation. Phases are all required for all species.
What are the attitude components : What are the attitude components? How do they shape marketing decisions?
Why does healthcare cost so much in us-charge of drug safety : Why does healthcare cost so much in the US? What can we do about obesity? Why is the US 40th in the world in infant morality? What is the future of the ACA?

Reviews

Write a Review

 

Other Subject Questions & Answers

  Determining the information on charitable trusts

Critically evaluate the bases upon which the courts have sought to restrict the involvement of charities in the political process.

  How does an employee have upper hand in today''s time

How does an employee have the "upper hand" in today's time? When you think about it jobs are scarce right now so if a person doesn't do what the organization wants it will find someone else. What can be done to grow this relationship between employee..

  Address a specific ethical dilemma

Address a specific ethical dilemma, in relation to the ethical standards of human service professionals, in which you either anticipate difficulty or have experienced difficulty in ethical practice due to a conflict or discordance between ethical pra..

  Department of employment security

Please describe what the Issue, Rule, Application and what the conclusion would be. Substance abuse, employment, Overstreet v. Illinois Department of Employment Security.

  North-south relations in security and economic

"North-South relations in security and economic areas will be the predominant area of conflict in the 21st century."  Do you agree with this statement?

  How are things going

When we ask someone a question such as, "How are things going" also we either already know answer or don't actually care what answer is, we are practicing.

  Influence of alcohol and possession of marijuana

Tony was a 16-year-old juvenile who was picked up for driving under the influence of alcohol and possession of marijuana. He was evaluated and taken to juvenile detention.

  Evaluate the risks of the project and key risk factors

Evaluate the risks of the project and key risk factors. If you were in charge of managing this project, what steps would you have taken to control the risk in the project and what else would you have done differently to increase the chances for succe..

  Voter choice in 2008 presidency campaign

What factors explain voter choice in 2008 presidency campaign between Barack Obama and John Mccain?

  Organization''s anti-virus policy

Should an organization's anti-virus policy specify that anti-virus applications will be configured to quarantine infected files instead of  deleting them automatically? Why or why not?

  Moving average forecast

If responsiveness to recent data is important to the forecaster, then the number of periods used in a moving average forecast

  Challenges for the overall uk health care system

Analyze and discuss three issues that are creating challenges for the overall UK health care system.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd