4

Finding middle element in a Linked list

 9 months ago
source link: https://www.geeksforgeeks.org/videos/finding-middle-element-in-a-linked-list/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Finding middle element in a Linked list

Hi. We will see this question which is to
August 31, 2023 |270 Views
Finding middle element in a Linked list
SDE Sheet, GFG SDE Sheet, linked-list
 Save  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

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK