• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests
August 31, 2023 |760 Views
Finding middle element in a Linked list
  Share   Like
Description
Discussion

This video is part of the Linked List section in the GFG SDE Sheet.

In this video, we are given a singly linked list of N nodes. Our task is to find the middle of the linked list. 
For example, if the linked list is 1-> 2->3->4->5, then the middle node of the list is 3.
If there are two middle nodes(in case, when N is even), print the second middle element.
For example, if the linked list given is 1->2->3->4->5->6, then the middle node of the list is 4.

Example :

Input:
LinkedList: 1->2->3->4->5
Output: 3 

Explanation: 
The middle of the linked list is 3.

Try it out before watching the implementation of the problem in the video. We recommend watching the video, even if you can solve the problem. You may discover something new. All the best!!!

Do check out:-

Article: https://www.geeksforgeeks.org/write-a-c-function-to-print-the-middle-of-the-Linked-list/
Problem: https://practice.geeksforgeeks.org/problems/finding-middle-element-in-a-linked-list/1
SDE Sheet: https://www.geeksforgeeks.org/sde-sheet-a-complete-guide-for-sde-preparation/
 

Read More