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
Overlay Graph: It overlay the content of two graphs that shares an ordinary x-axis. Left Y-axis on the merged graph show's the present graph's value & Right Y-axis illustrate the v

What is a pointer? The register or memory location that having the address of an operand is known as a pointer.

Q. For function F(x,y,z) = ∑m(0,1,2,6,7) using TRUTH TABLE only.   1. Find SOP expression 2. Implement this simplified expression using two level AND-to-OR gate network 3. I

Arithmetic-logic section in computer system: The   arithmetic-logic section performs arithmetic   operations, such subtraction, addition, multiplication, and division. Throug

Explain the multiple bus organization structure with neat diagram. The multiple bus organization is using more buses instead of one bus to decrease the number of steps needed an

what is critical section problem in operating system with diagram

Explain the significance of init() and destroy( ) methods of an applet? Also explain two ways of invoking an applet. The init( ) method is utilized for fundamental initializati

Explain the role of a bus arbiter in a multiprocessor configuration. Bus arbiter: Which functions to resolve priority between bus masters and allows only one device at a time t

Why some languages are not decidable or even Turing - recognizable?  The  reason  that  there  are  uncountable  many  languages  yet  only  countably many  Turing  machines.

Indirect addressing A memory location is given that holds another memory location. This second memory location holds the real data. This mechanism solves problems caused by rea