Which traversal technique is used to visit each node of a linked list exactly…
2025
Which traversal technique is used to visit each node of a linked list exactly once?
- A.
Preorder traversal
- B.
Inorder traversal
- C.
Postorder traversal
- D.
Linear traversal
Attempted by 645 students.
Show answer & explanation
Correct answer: D
Linear traversal is used to visit each node of a linked list exactly once. In this method, we start from the head node and move sequentially to the next node using the pointer until the end of the list is reached. This ensures that every node is visited exactly once without repetition or skipping.
Preorder, inorder, and postorder traversals are specific to tree data structures, where nodes have left and right children. Since a linked list is a linear structure with no hierarchical relationships, these tree-based traversal methods are not applicable.
हिन्दी उत्तर: लिंक्ड लिस्ट के प्रत्येक नोड को ठीक एक बार विजिट करने के लिए रेखीय ट्रैवर्सल का उपयोग किया जाता है। इस विधि में, हम हेड नोड से शुरू करते हैं और अगले नोड की ओर पॉइंटर का उपयोग करके अगले नोड तक जाते हैं, जब तक कि सूची का अंत नहीं हो जाता। इससे यह सुनिश्चित होता है कि प्रत्येक नोड को ठीक एक बार ही विजिट किया जाता है।
प्रीऑर्डर, इनऑर्डर और पोस्टऑर्डर ट्रैवर्सल ट्री डेटा संरचनाओं के लिए विशिष्ट होते हैं, जहाँ नोड्स में बाएँ और दाएँ बच्चे होते हैं। चूँकि लिंक्ड लिस्ट एक रेखीय संरचना है और कोई पदानुक्रमिक संबंध नहीं होता है, इसलिए ये ट्री-आधारित ट्रैवर्सल विधियाँ उपयुक्त नहीं होती हैं।