Exercises Videos Notes Multiple-choice questions

Related books

Algorithms Algorithm Design The Art of Mathematics: Coffee Time in Memphis Mathematical Mind-Benders Algorithms Combinatorial Problems and Exercises Algorithmic Puzzles Mathematical Puzzles: A Connoisseur's Collection Suggest a Book
2

Corrupted linked-list

Level: unknown
 

posted Jun 12 '12

kintali gravatar image Shiva Kintali flag of United States
691 1 6 22
http://www.cs.princeton.e...

updated Oct 19 '12

You are given a pointer to the head of singly linked list. Usually, each node in the list only has a pointer to the next element, and the last node’s pointer is NULL. Unfortunately, your list might have been corrupted, so that the last node has a pointer back to some other node in the list.

  • Design a linear-time algorithm (using only a constant extra space) to determine whether the linked list is corrupted. Your algorithm must not modify the list.

  • Find the node in linear time, where last node is pointing.

Source: folklore
Printable version LaTeX source
delete flag offensive retag edit

Stats

Posted: Jun 12 '12

Seen: 166 times

Last updated: Oct 19 '12