Is there any difference in the speed of execution between linear…
2023
Is there any difference in the speed of execution between linear serach(recursive) vs linear search(lterative)?
- A.
Both execute at same speed
- B.
Linear search(recursive) is faster
- C.
Linear search(Iterative) is faster
- D.
Cant be said
Attempted by 81 students.
Show answer & explanation
Correct answer: C
Explanation: The iterative version of linear search is faster than the recursive version because the recursive approach involves function call overhead and stack management for each call. These operations consume additional time and memory, making the recursive method slower. In contrast, the iterative method uses a loop and does not require function calls or stack frames, resulting in better performance. Therefore, the iterative method executes faster.
हिन्दी उत्तर: रैखिक खोज (पुनरावृत्ति) विधि रैखिक खोज (पुनरावृत्ति) विधि की तुलना में तेज़ होती है क्योंकि पुनरावृत्ति विधि में प्रत्येक कॉल के लिए फ़ंक्शन कॉल ओवरहेड और स्टैक प्रबंधन शामिल होता है। ये ऑपरेशन अतिरिक्त समय और मेमोरी का उपयोग करते हैं, जिससे पुनरावृत्ति विधि धीमी हो जाती है। दूसरी ओर, पुनरावृत्ति विधि एक लूप का उपयोग करती है और फ़ंक्शन कॉल या स्टैक फ्रेम की आवश्यकता नहीं होती है, जिससे बेहतर प्रदर्शन मिलता है। इसलिए, पुनरावृत्ति विधि तेज़ चलती है।