Detecting a cycle
Download
1 / 48

uncompressed - PowerPoint PPT Presentation


  • 279 Views
  • Updated On :

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 . . .

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'uncompressed' - andrew


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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript





Slide6 l.jpg

Detecting a cycle

p

Cycle detected at p

L


Slide7 l.jpg

Now restore the listusing the saved pointers

p

L








Slide14 l.jpg

How much time and space?

O(N)time

p

L

O(N)space for stack


Slide15 l.jpg

Detecting a cyclewith two-speed pointers

L

p

q


Slide16 l.jpg

Detecting a cyclewith two-speed pointers

L

p

q


Slide17 l.jpg

Detecting a cyclewith two-speed pointers

L

p

q


Slide18 l.jpg

Detecting a cyclewith two-speed pointers

L

p

q


Slide19 l.jpg

Detecting a cyclewith two-speed pointers

L

p

q


Slide20 l.jpg

Detecting a cyclewith two-speed pointers

p

L

q


Slide21 l.jpg

Detecting a cyclewith two-speed pointers

p

L

q


Slide22 l.jpg

Detecting a cyclewith two-speed pointers

L

p

q


Slide23 l.jpg

Detecting a cyclewith two-speed pointers

L

p

q


Slide24 l.jpg

Detecting a cyclewith two-speed pointers

L

Cycle detected

p

q



Slide26 l.jpg

Two-speed method:a larger example


Slide27 l.jpg

Two-speed method:a larger example


Slide28 l.jpg

Two-speed method:a larger example


Slide29 l.jpg

Two-speed method:a larger example


Slide30 l.jpg

Two-speed method:a larger example


Slide31 l.jpg

Two-speed method:a larger example


Slide32 l.jpg

Two-speed method:a larger example


Slide33 l.jpg

Two-speed method:a larger example


Slide34 l.jpg

Two-speed method:a larger example


Slide35 l.jpg

Two-speed method:a larger example


Slide36 l.jpg

Two-speed method:a larger example


Slide37 l.jpg

Two-speed method:a larger example


Slide38 l.jpg

Two-speed method:a larger example


Slide39 l.jpg

Two-speed method:a larger example


Slide40 l.jpg

Two-speed method:a larger example


Slide41 l.jpg

Two-speed method:a larger example


Slide42 l.jpg

Two-speed method:a larger example


Slide43 l.jpg

Two-speed method:a larger example


Slide44 l.jpg

Two-speed method:a larger example


Slide45 l.jpg

Two-speed method:a larger example


Slide46 l.jpg

Two-speed method:a larger example

Cycle detected!



Slide48 l.jpg

How much time and space?

O(1)space

O(N)time


ad