← 回題庫

卷別

資料結構

選擇

國立中央大學 2026 · 考試 · 第 12 題

(承上題 Floyd's Cycle Detection Algorithm 的設定:AA 為表頭到環起點的距離,LL 為環長。)

If we change the rabbit's speed to "3 steps each time" and the tortoise's speed to "1 step each time", can this algorithm still detect the cycle?

  • (A)
    No, the rabbit might jump over the tortoise to reach NULL.
  • (B)
    Maybe, check if LL is a multiple of BB.
  • (C)
    Maybe, check if LL is a multiple of 2.
  • (D)
    Perhaps, we can check if L+A−BL+A-B and 2 are coprime.

標準解析

AI 生成