CS FundamentalsVery hardGATE CS

A media player has states Stopped, Playing and Paused and events play, pause and stop. Valid transitions: Stopped–play→Playing, Playing–pause→Paused, Playing–stop→Stopped, Paused–play→Playing, Paused–stop→Stopped. How many state–event pairs are invalid (for negative tests), and what is the fewest events in one sequence from Stopped that covers every valid transition?

  1. A. 4 invalid pairs; 5 events
  2. B. 5 invalid pairs; 7 events
  3. C. 4 invalid pairs; 6 events
  4. D. 4 invalid pairs; 7 events

Correct answer: D. 4 invalid pairs; 7 events

3 states × 3 events = 9 pairs, of which 5 are valid, so 4 are invalid. Using each transition exactly once would require starting at Paused (one more exit than entry), so a walk from Stopped must repeat at least two transitions: play, pause, play, stop, play, pause, stop covers all 5 in 7 events.

More Software Engineering, Git and Cloud Basics questions

Exams that ask this topic