Fair attraction In olden days, one could encounter the following attraction at a
ID: 3730902 • Letter: F
Question
Fair attraction In olden days, one could encounter the following attraction
at a fair. A light bulb was connected to several switches in such a way that it
lighted up only when all the switches were closed. Each switch was controlled
by a push button; pressing the button toggled the switch, but there was no
way to know the state of the switch. The object was to turn the light bulb on.
Design an algorithm to turn on the light bulb with the minimum number of
button pushes needed in the worst case for n switches.
Explanation / Answer
Answer
Fair attraction:
consider Even and Odd thought .i.e., first even number switches will be check then odd number switches.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.