Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

It is a well-researched fact that men in a restroom generally prefer to maximize

ID: 3547326 • Letter: I

Question

It is a well-researched fact that men in a restroom generally prefer to maximize their distance from already occupied stalls, by occupying the middle of longest seqeunce of un occupied places.

For example, consider the situation where ten stalls are empty.

_ _ _ _ _ _ _ _ _ _

The first visitor will occupy a middle position:

_ _ _ _ _ x _ _ _ _

The next visitor will be in the middle of the empty area at the left.

_ _ x _ _ x _ _ _ _

Write a program that reads the number of stalls and then prints out diagrams in the format given above when the stalls become filled, one at a time.

Hint: Use an array of boolean values to indicate whether a stall is occupied.

Explanation / Answer

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote