How do you find out if a linked-list has an end, Computer Engineering

By 2 pointers you can find it. One of them goes 2 nodes each time. The second one goes at 1 node each time. If there is a cycle, the one that goes 2 nodes every time will eventually meet the one that goes slower. If that is the case, then you will identify the linked-list is a cycle.

 

 

Posted Date: 4/8/2013 5:21:02 AM | Location : United States







Related Discussions:- How do you find out if a linked-list has an end, Assignment Help, Ask Question on How do you find out if a linked-list has an end, Get Answer, Expert's Help, How do you find out if a linked-list has an end Discussions

Write discussion on How do you find out if a linked-list has an end
Your posts are moderated
Related Questions
I am confuse how i start my coding in this topic please help me to start my coding.

Is the basic list deleted when the new list is created? No.  It is not removed and you can return back to it using one of the standard navigation functions like clicking on th

Binary is an alternative number system which works very good for computers. Humans have ten fingers; that's probably why we use ten digits (0, 1, 2, 3, 4, 5, 6, 7, 8, and 9) in our

Structural hazards - computer architecture: A structural hazard takes place when a part of the processor's hardware is required by 2 or more than two instructions at the same

Explain how SAP GUI handles output screen for the user. The SAP front-end s/w can either run on the similar computer or on dissimilar computers given for that purpose.  User t

Goals - artificial intelligence: One desirable way to make perfect an agent's performance is to enable it to have some details of what it is trying to complete. If it is given

1. The missionaries and cannibals problem. Three missionaries and three cannibals are on the left river bank, with a boat that can hold one or two people. If on either side of the

How and what data is collected - Weather simulation -  Sensors measure pressure, relative humidity, temperature and wind speed and wind direction -  Sensors are placed in w

what are advantages and disadvantages of bresenham''s line drawing algorithm?

Q. Convert the following from octal to binary, decimal, hexadecimal and BCD. a) 7.7 b) 4037 c) 23.34