A Linked List is a collection of nodes where each node points to the next node in the list.
Finding the middle node of a Linked List can be solved by using a small trick that makes the solution efficient.
Option 1 - The Brute force approach takes more than n traversals through the list. We first find the length of the linked list and then we find the middle node.
Option 2 - The second approach uses a small trick by creating two pointers i.e. the slow pointer and the fast pointer. In every iteration the fast pointer moves two steps while the slow pointer moves only 1 step. When the fast pointer reaches the end of the list, the slow pointer will be at the middle node.
#linkedlists #datastructures #linkedlistmiddlenode #algorithms
++++++++++++++++++++++++++++++++++++++++++++++++++++
My General Tech Blog : http://www.progressivecoder.com
My Web Dev Focused Blog : https://www.progressivewebninja.com
My Github URL : https://www.github.com/dashsaurabh
#stacks #datastructures #algorithms #
++++++++++++++++++++++++++++++++++++++++++++++++++++
Sound Courtesy - https://www.bensound.com/