PREP
DOOR
Explore
Mock Test
All India Test
Test Package
Topic-wise Test
Android App
X Close
Home
Profile
Explore
PrepDoor
New
My Assets
Crypt Hunt
Word List
Login |
Register
Select an option to search:
GPL Search
Google Custom Search
PSU Papers
Company Papers
Companies Fact
Online Test
Prep Tool
MBA Question
Gate Question
IES Question
Exam Papers:
TCS
Infosys
Wipro
IBM
Accenture
Patni
CTS
Sapient
Aricent
HCL
Syntel
3i Infotech
L&T Infotech
Capgemini
ITC Infotech
You need to enable javascript to view this page properly.
Given a singly linked list, find the node in the middle.
Click for Solution
puneeth
node cur,cur1;
cur=first;
cur1=first;
while(cur1!=null)
{
cur=cur->link;
cur1=cur1->link;
cur1=cur1->link;
}
printf("middle node is %d",cur->info);
Comment
Hide
puneeth
1. take two references to first node like,
cur=first and cur1=first.
2. wen cur is traversed once ,let cur1 to traverse twice so that when
cur1 is at the end of list cur will be pointing to middle of the list.
Comment
Hide
[Insert Code]
Post your query
Comment