Associate software engineer interview questions shared by candidates
can we find the end of circular linked list?
http://www.algorithmist.com/index.php/Linked_List Circular Lists Normally the last node in a linked list points to null. The tail node of a circularly linked list points to the head node. The advantage this offers is that, given any node, you can traverse the entire linked list. (Normally, you can access only items that follow a given node.) When you revisit the given node, you know you've traversed the entire list. This of course means the list head is less important. The disadvantage is that it is slightly more complicated to add an item to a list. Circular list insertion is made easier by adding the item after the head, as opposed to before it (as in a stack). The item is inserted between head and head->next. The following function should illustrate this point.
http://ostermiller.org/find_loop_singly_linked_list.html Simultaneously go through the list by ones (slow iterator) and by twos (fast iterator). If there is a loop the fast iterator will go around that loop twice as fast as the slow iterator. The fast iterator will lap the slow iterator within a single pass through the cycle. Detecting a loop is then just detecting that the slow iterator has been lapped by the fast iterator.
See Interview Questions for Similar Jobs
- Software Engineer
- Senior Software Engineer
- Software Developer
- Java Developer
- Trainee Software Engineer
- Associate Engineer
- Business Analyst
- Technical Support Engineer
- Software Development Engineer
- Graduate Engineer Trainee
- Technical Associate
- Systems Engineer
- QA Engineer