Explain how to find 3rd element from end in a linked list in one pass?



Explain how to find 3rd element from end in a linked list in one pass?..

Answer / Mithilesh Prasad

One approach is to maintain two pointers slow and fast initially at the head of the list. Move fast two steps ahead for each step that slow moves forward. Once fast reaches the end, slow will point to the second to last node. Move slow one more step forward to get the third-to-last node.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Data Structures Interview Questions

How do I sort hashset?

1 Answers  


What's the difference between a hashtable and a hashmap?

1 Answers  


Evaluate the following prefix expression " ++ 26 + - 1324"

24 Answers   College School Exams Tests, Patni,


What type of algorithm is binary search?

1 Answers  


Explain singly linked list in short.

1 Answers  


What is the limit of arraylist?

1 Answers  


There are 8, 15, 13, 14 nodes were there in 4 different trees. Which of them could have formed a full binary tree?

1 Answers  


What is definition list?

1 Answers  


Can map contain duplicate keys?

1 Answers  


Is heap sort adaptive?

1 Answers  


What is array indexing?

1 Answers  


State the rules to be followed during infix to postfix conversions?

1 Answers  


Categories