Question
Option 4 : 4
Detailed Solution
सही उत्तर 4 है।
Question:
In a singly linked list of 7 nodes, the slow pointer moves one node at a time and the fast pointer moves two nodes at a time, both starting at the head. When the fast pointer reaches the last node, the slow pointer is at which node number (1-indexed)? / 7 नोड्स की एकल लिंक्ड लिस्ट में, धीमा पॉइंटर एक-एक नोड और तेज़ पॉइंटर दो-दो नोड चलता है, दोनों head से शुरू करते हैं। जब तेज़ पॉइंटर अंतिम नोड पर पहुँचता है, तो धीमा पॉइंटर किस नोड संख्या (1-सूचकांकित) पर होगा?
Correct Answer: 4
The fast pointer visits nodes 1, 3, 5, 7 (three jumps of two). In the same three steps the slow pointer advances three nodes: 1 -> 2 -> 3 -> 4, so it is at node 4, the middle of the list. / तेज़ पॉइंटर नोड 1, 3, 5, 7 देखता है (दो-दो के तीन छलांग)। उन्हीं तीन चरणों में धीमा पॉइंटर तीन नोड आगे बढ़ता है: 1 -> 2 -> 3 -> 4, अतः वह नोड 4 पर होता है, जो लिस्ट का मध्य है।