← 回題庫

卷別

資料結構

選擇

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

To detect whether a cycle exists in a singly linked list, the most famous Floyd's Cycle Detection Algorithm (the tortoise and the rabbit algorithm) uses two metrics. Assume the distance from the beginning of the linked list to the start of the cycle is AA, and the length of the cycle is LL. Assume the rabbit's speed is twice that of the tortoise. When the tortoise and rabbit meet, assume the tortoise has traveled a distance BB within the cycle. What is the total distance the rabbit has traveled at this point?

  • (A)
    A+BA + B
  • (B)
    2(A+B)2(A + B)
  • (C)
    A+B+LA + B + L
  • (D)
    2A+B2A + B

標準解析

AI 生成