CS FundamentalsVery hardProduct company interview · GATE level

A leaky bucket holds at most 5 packets. In each clock tick, newly arrived packets are first placed in the bucket (those that do not fit are dropped), and then up to 2 packets are sent. The bucket starts empty and the arrivals in ticks 1 to 6 are 4, 5, 0, 6, 1 and 3 packets. After tick 6, how many packets have been dropped and how many are still waiting in the bucket?

  1. A. 4 dropped; 3 waiting
  2. B. 2 dropped; 5 waiting
  3. C. 4 dropped; 5 waiting
  4. D. 7 dropped; 0 waiting

Correct answer: A. 4 dropped; 3 waiting

Tick 1: 4 in, send 2, 2 left. Tick 2: 2 + 5 = 7, two dropped, 5 held, send 2, 3 left. Tick 3: no arrivals, send 2, 1 left. Tick 4: 1 + 6 = 7, two dropped, send 2, 3 left. Tick 5: 3 + 1 = 4, send 2, 2 left. Tick 6: 2 + 3 = 5 fits exactly, send 2, 3 left. Total dropped 4, with 3 waiting. Check: 19 arrived = 12 sent + 4 dropped + 3 waiting. Reporting 5 waiting forgets the send in tick 6.

More Computer Networks questions

Exams that ask this topic