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
Define seek time and latency time.  The time taken by the head to move to the appropriate cylinder or track is known as seek time. Once the head is at right track, it must wai

What can you say about the existence of a stationary point in the interval [ 1; 3] for the function f (x) = x 2 2x 3.

Define a register. Ans:  Register:   A register contain a group of flip-flops and gates which effect their transition. The flip flops hold the binary information and the g

What is write-through protocol? For a write operation using write-through protocol during write-hit: The cache location and the major memory location are updated concurrently.

How blocking and non blocking statements get executed? Execution of blocking assignments can be viewed just like a one-step process: 1. Evaluate RHS (right-hand side equatio

Q. Can you explain about Internet Protocol? Internet protocol specifies the rules which define the details of how computers communicate. It specifies exactly how a packet shoul

Continuing in main, write a loop that will read from the ifstream that reads enough information to  create a person object (i.e. first name, last name, and weight).  Exit the loop

State the basic properties of this analytical engine The basic properties of this analytical engine are: It was a common purpose programmable machine. It had provisi

Every computer connected to Internet has a unique address. Let's just say your IP address is 1.2.3.4 and you want to send a message to computer with IP address 5.6.7.8. Message you

What are the critical capabilities for superior firm performance in e-commerce? Three firm capabilities which are critical for superior firm performance within e-commerce are: