Question: A linked list contains a cycle if, starting from some node p, following a sufficient number of next links brings us back to node p.
a. Design an O(N) algorithm to determine if the list contains a cycle. You may use O(N) extra space.
b. Repeat part (a), but use only O(1) extra space.
Step by Step Solution
3.29 Rating (164 Votes )
There are 3 Steps involved in it
b Use two iterators p and q both initially at the ... View full answer
Get step-by-step solutions from verified subject matter experts
Document Format (1 attachment)
1486-C-S-A(309).docx
120 KBs Word File
