Let's simulate a game 'Hot potato'. It is the game where children stand in a circle and pass some objects to their neigh

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

Let's simulate a game 'Hot potato'. It is the game where children stand in a circle and pass some objects to their neigh

Post by answerhappygod »

Let's simulate a game 'Hot potato'. It is the game where children stand in a circle and pass some objects to their neighbours. At a certain point in the game, the action is stopped and the child who has the object is removed from the circle. Play continues until only one child is left. Let's simulate the scenario by removing a child when the count becomes 7.
Our program will input a list of names and a constant, call it "num," to be used for counting. It will return the name of the last person remaining after repetitive counting by num.
To simulate the circle, we will use a queue. Assume that the child at the front of the queue says 1 and joins back the queue (dequeued and enqueued immediately). The child at the front will say 2 and joins back the queue. This repeats until a child says 7 (dequeued permanently). The game again starts from count 1. This process will continue until only one name remains (the size of the queue is 1).
Let S Simulate A Game Hot Potato It Is The Game Where Children Stand In A Circle And Pass Some Objects To Their Neigh 1
Let S Simulate A Game Hot Potato It Is The Game Where Children Stand In A Circle And Pass Some Objects To Their Neigh 1 (103.66 KiB) Viewed 37 times
Queues Problem-3 a Let's simulate a game 'Hot potato'. It is the game where children stand in a circle and pass some objects to their neighbours. At a certain point in the game, the action is stopped and the child who has the object is removed from the circle. Play continues until only one child is left. Let's simulate the scenario by removing a child when the count becomes 7. Our program will input a list of names and a constant, call it “num,” to be used for counting. It will return the name of the last person remaining after repetitive counting by num. To simulate the circle, we will use a queue. Assume that the child at the front of the queue says 1 and joins back the queue (dequeued and enqueued immediately). The child at the front will say 2 and joins back the queue. This repeats until a child says 7 (dequeued permanently). The game again starts from count 1. This process will continue until only one name remains (the size of the queue is 1). rear Brad Kent Jane Susan David Bill front enqueue dequeue Go to the rear (Pass the potato) rear Bill Brad Kent Jane Susan David front
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply