-
Notifications
You must be signed in to change notification settings - Fork 794
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adopted Brent's algorithm for cycle detection
The previous cycle detection algorithm (a naive check against the largest possible tail list) is simple and gets the job done, but has the potential to take a very long time on disks with many blocks. Brent's algorithm, on the other hand, takes at most 2x the number of blocks in the tail list. Originally naive cycle detection was chosen over Floyd's algorithm to avoid the extra complexity of managing two desynced traversals for every traversal of the tail list, but Brent's algorithm is very well suited for our use case, requiring only we keep track of an additional mdir pointer on the stack as we traverse.
- Loading branch information
Showing
1 changed file
with
54 additions
and
20 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