Find the middle of a given linked list using recursion

4.5

4 votes
Very-Easy
Problem

Given a singly linked list, find middle of the linked list. For example, if given linked list is 1->2->3->4->5 then output should be 3.

If there are even nodes, then there would be two middle nodes, we need to print second middle element. For example, if given linked list is 1->2->3->4->5->6 then output should be 4.

Note: Insert function should add nodes in the linked list.

INPUT: First line No. of Node n in linked list. Second Line Should be n Space Seprated Data of LinkedList.

Output: Output Should be middle element of Linked .

Time Limit: 5
Memory Limit: 256
Source Limit:
Editor Image

?