From 3f0b3dc2d14ae0ee6b103f9b901be1e36654c8c1 Mon Sep 17 00:00:00 2001 From: Michael Hayter Date: Mon, 14 Apr 2025 16:01:27 -0400 Subject: [PATCH] Update tortoise_and_hare.md Center tags were not allowing rendering of images in mkdocs format --- src/others/tortoise_and_hare.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/others/tortoise_and_hare.md b/src/others/tortoise_and_hare.md index 9d2ba0a96..c15f011e6 100644 --- a/src/others/tortoise_and_hare.md +++ b/src/others/tortoise_and_hare.md @@ -7,7 +7,8 @@ tags: Given a linked list where the starting point of that linked list is denoted by **head**, and there may or may not be a cycle present. For instance: -
!["Linked list with cycle"](tortoise_hare_algo.png)
+!["Linked list with cycle"](tortoise_hare_algo.png) + Here we need to find out the point **C**, i.e the starting point of the cycle. @@ -27,7 +28,7 @@ So, it involved two steps: 6. If they point to any same node at any point of their journey, it would indicate that the cycle indeed exists in the linked list. 7. If we get null, it would indicate that the linked list has no cycle. -
!["Found cycle"](tortoise_hare_cycle_found.png)
+!["Found cycle"](tortoise_hare_cycle_found.png) Now, that we have figured out that there is a cycle present in the linked list, for the next step we need to find out the starting point of cycle, i.e., **C**. ### Step 2: Starting point of the cycle @@ -81,7 +82,7 @@ When the slow pointer has moved $k \cdot L$ steps, and the fast pointer has cove Lets try to calculate the distance covered by both of the pointers till they point they met within the cycle. -
!["Proof"](tortoise_hare_proof.png)
+!["Proof"](tortoise_hare_proof.png) $slowDist = a + xL + b$ , $x\ge0$