CIS3590-G1B / GROUP-1B-Java

All Algorithms implemented in Java
MIT License
1 stars 0 forks source link

ISSUE#4.1-BRIAN - ISSUE SELECTION - Adding Hare and Tortoise Algorithm #5693 #4

Closed ba-00001 closed 1 month ago

ba-00001 commented 1 month ago

What would you like to propose? I would like to propose the addition of the "Hare and Tortoise Algorithm" (also known as Floyd’s cycle detection algorithm) to the repository. This algorithm is useful for detecting cycles in a sequence, particularly in linked lists. Implementing this in Java would be a valuable addition to the existing algorithms in the repository.

Issue details The Hare and Tortoise algorithm works by having two pointers move through the sequence at different speeds: one (the hare) moves two steps at a time, while the other (the tortoise) moves one step at a time. If there is a cycle, the two pointers will eventually meet. This algorithm is commonly used in problems involving linked lists to detect cycles efficiently, with O(n) time complexity and O(1) space complexity.

Additional Information The proposed implementation will include both a standard use case for detecting a cycle in a linked list and a brief explanation of its time and space complexity. The code will follow Java best practices and will include comprehensive test cases to ensure functionality and correctness. This algorithm is widely recognized and often appears in technical interviews, making it a valuable resource for learners and developers.

[FEATURE REQUEST] Adding Hare and Tortoise Algorithm #5693 https://github.com/TheAlgorithms/Java/issues/5693