1 / 48
Detecting a cycle
480 likes | 845 Vues
Detecting a cycle L Detecting a cycle L p Detecting a cycle L p stack Detecting a cycle L p stack Detecting a cycle L p Detecting a cycle p Cycle detected at p L Now restore the list using the saved pointers p L Restoring . . . L p Restoring . . . L p Restoring . . .
Télécharger la présentation
Detecting a cycle
An Image/Link below is provided (as is) to download presentation
Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.
Content is provided to you AS IS for your information and personal use only.
Download presentation by click this link.
While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.
During download, if you can't get a presentation, the file might be deleted by the publisher.
E N D
Presentation Transcript
Detecting a cycle L p stack
Detecting a cycle L p stack
Detecting a cycle p Cycle detected at p L
Restoring . . . L p
Restoring . . . L p
Restoring . . . L p
Restoring . . . L p
How much time and space? O(N)time p L O(N)space for stack
Detecting a cyclewith two-speed pointers L Cycle detected p q
Two-speed method:a larger example Cycle detected!
How much time and space? O(1)space O(N)time
More Related