Solution 2 : How to find the middle element of Linked list | Two Pointer | Linked List Algorithm

preview_player
Показать описание
In this video we are going to learn about the two pointer method of finding middle element of linked list. we will maintain a slow pointer and a fast pointer. Then we will move slow pointer by one and fast pointer by two units. When we will not be able to move the fast pointer then at that particular time the position of slow pointer will give the middle node of the linked list

Рекомендации по теме
Комментарии
Автор

Awesome explaination bro.thank you so much.

mohammedsuhailbasha
Автор

What’s the time complexity for this second algorithm. Looks like nlog(n)

bencipherx
Автор

Bro, can you please explain some important programs given in w3resource Java exercises...the way you are explaining is exceptional

raghuvarun
Автор

what if there are even number of nodes ? then there should be two positons. So, how slow pointer is gonaa point two positions at the same time.

akshaykr
Автор

If there are more than 5 element your code fails.
It will gie the third last element

bleed.black