Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
+++ | ||
title = "Cycle Finding Algorithms" | ||
date = 2023-12-19T00:27:00+08:00 | ||
tags = ["cycle-finding"] | ||
categories = ["Data-Structure-and-Algorithm"] | ||
draft = false | ||
image = "/images/icons/TortoiseHare.jpg" | ||
libraries = ["mathjax"] | ||
description = "this is a description" | ||
+++ | ||
|
||
## Floyd's tortoise and hare {#floyd-s-tortoise-and-hare} | ||
|
||
{{< figure src="/images/posts/cycle-finding/tortoise-and-hare.svg" caption="<span class=\"figure-number\">Figure 1: </span>tortoise and hare" >}} | ||
|
||
hare and tortoise both starts from point **Start**, at speed of \\(2\\) and \\(1\\) respectively. They'll meet at some point in the cycle. | ||
|
||
when they meet, hare traveled \\(S\_2 - S\_{1}\\) more points than tortoise. We have: (\\(\lambda\\) is the cycle length) | ||
|
||
\\[ | ||
S\_{2} - S\_{1} = 0 = S\_{1} = x + m \pmod{\lambda} | ||
\\] | ||
|
||
after they meet, one starts over from Start point, the other starts from Meet point, at speed of \\(1\\), they'll meet again at **Cycle Start** point. because: | ||
|
||
\\[ | ||
x = x + m + x \pmod{\lambda} | ||
\\] |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
b887164
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
blog-src – ./
blog-src-ky13.vercel.app
blog-src-git-master-ky13.vercel.app
k4i.top