🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: TCP Congestion Control: all 10 questions

Quiz: TCP Congestion Control · Question 7 of 10

What does this print? (code)

What does this print?

def cwnd_trace(rtts, ssthresh, loss_at=(), kind="Tahoe"):
    cwnd, out = 1, []
    for r in range(1, rtts + 1):
        out.append(cwnd)
        if r in loss_at:
            ssthresh = max(cwnd // 2, 2)
            cwnd = 1 if kind == "Tahoe" else ssthresh
            continue
        nxt = cwnd * 2 if cwnd < ssthresh else cwnd + 1
        if cwnd < ssthresh < nxt:
            nxt = ssthresh
        cwnd = nxt
    return out

print(cwnd_trace(7, 6))
  1. A.[1, 2, 4, 8, 9, 10, 11]
  2. B.[1, 2, 4, 6, 7, 8, 9]
  3. C.[1, 2, 3, 4, 5, 6, 7]
  4. D.[1, 2, 4, 6, 12, 13, 14]
Answer & explanation

Correct answer: [1, 2, 4, 6, 7, 8, 9]

Doubling from 4 would pass ssthresh 6, so cwnd stops at 6 and then grows by 1 each RTT.

Can you get the rest right without peeking?

Take the timed Quiz: TCP Congestion Control quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →