Data Structures and Algorithms — MCQ Practice

Hindi aur English dono mein practice karo — click karo answer check karne ke liye.

📚 1018 Questions 🌐 Hindi + English ✅ Free
भाषा / Language:
1018 questions

Question 901

EN + हिं
GB What is the output: auto sp=make_shared(42); cout<
IN आउटपुट क्या है: auto sp=make_shared(42); अदालत
1 1
2 2
Error गलती
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) One owner sp; use_count=1.
व्याख्या (हिन्दी) एक मालिक एसपी; उपयोग_गिनती=1.
🎯 Exam Perspective
Data Structures and Algorithms से जुड़ा यह सवाल उन students के लिए काम का है जो Railway, SSC, Banking और Defence परीक्षाओं की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 902

EN + हिं
GB The output of: auto sp=make_shared(42); auto sp2=sp; cout<
IN इसका आउटपुट: auto sp=make_shared(42); ऑटो sp2=sp; अदालत
1 1
2 2
3 3
Error गलती
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Two owners sp and sp2; use_count=2.
व्याख्या (हिन्दी) दो मालिक एसपी और एसपी2; उपयोग_गिनती=2.
🎯 Exam Perspective
SSC, Railway, Banking और State PCS जैसी परीक्षाओं में Data Structures and Algorithms से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें।

Question 903

EN + हिं
GB The output of: thread t1([]{cout<<"A";}); thread t2([]{cout<<"B";}); t1.join(); t2.join(); output is:
IN इसका आउटपुट: थ्रेड t1([]{cout
AB always एबी हमेशा
BA always बीए हमेशा
AB or BA (non-deterministic) एबी या बीए (गैर-नियतात्मक)
Error गलती
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Thread execution order is non-deterministic.
व्याख्या (हिन्दी) थ्रेड निष्पादन आदेश गैर-नियतात्मक है।
🎯 Exam Perspective
अगर आप SSC CGL, IBPS, RRB और State-level परीक्षाओं की तैयारी कर रहे हैं, तो Data Structures and Algorithms का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।

Question 904

EN + हिं
GB What is the output: atomic x=0; thread t1([&]{for(int i=0;i<1000;i++)x++;}); thread t2([&]{for(int i=0;i<1000;i++)x++;}); t1.join(); t2.join(); cout<
IN आउटपुट क्या है: परमाणु x=0; थ्रेड t1([&]{for(int i=0;i
1000 1000
2000 2000
Undefined (race condition) अपरिभाषित (दौड़ की स्थिति)
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) atomic prevents race; 2000 increments guaranteed.
व्याख्या (हिन्दी) परमाणु दौड़ को रोकता है; 2000 वेतन वृद्धि की गारंटी.
🎯 Exam Perspective
Data Structures and Algorithms के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे UPSC, SSC, Banking और Police भर्ती में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 905

EN + हिं Medium
GB Without atomic, same code above would give:
IN परमाणु के बिना, उपरोक्त समान कोड देगा:
Always 2000 हमेशा 2000
Undefined behavior (race condition on non-atomic x) अपरिभाषित व्यवहार (गैर-परमाणु x पर दौड़ की स्थिति)
Always 1000 हमेशा 1000
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Data race on non-atomic variable = undefined behavior.
व्याख्या (हिन्दी) गैर-परमाणु चर पर डेटा दौड़ = अपरिभाषित व्यवहार।
🎯 Exam Perspective
यह सवाल Data Structures and Algorithms category का है — difficulty level "Medium", और Railway, SSC, Banking और Defence परीक्षाओं के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 906

EN + हिं Medium
GB std::mutex::lock() blocks until:
IN std::mutex::lock() तब तक ब्लॉक रहता है:
Always returns हमेशा लौटता है
Mutex is acquired (other thread releases it) म्यूटेक्स का अधिग्रहण कर लिया गया है (अन्य थ्रेड इसे जारी करता है)
Timer expires टाइमर समाप्त हो रहा है
Thread terminates धागा समाप्त हो जाता है
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) lock() waits until mutex is available.
व्याख्या (हिन्दी) लॉक() म्यूटेक्स उपलब्ध होने तक प्रतीक्षा करता है।
🎯 Exam Perspective
यह प्रश्न Data Structures and Algorithms की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है — difficulty level "Medium"। इस तरह के प्रश्न अक्सर SSC, Railway, Banking और State PCS जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।

Question 907

EN + हिं Medium
GB std::try_lock() differs from lock() in:
IN std::try_lock() लॉक() से भिन्न है:
Same behavior वही व्यवहार
try_lock returns immediately (true if acquired, false if not) Try_lock तुरंत लौटाता है (यदि प्राप्त हुआ तो सही, नहीं तो गलत)
try_lock blocks ट्राई_लॉक ब्लॉक
try_lock throws ट्राई_लॉक फेंकता है
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) try_lock: non-blocking attempt to acquire mutex.
व्याख्या (हिन्दी) प्रयास_लॉक: म्यूटेक्स प्राप्त करने का गैर-अवरुद्ध प्रयास।
🎯 Exam Perspective
Data Structures and Algorithms से जुड़ा यह सवाल — difficulty level "Medium" उन students के लिए काम का है जो SSC CGL, IBPS, RRB और State-level परीक्षाओं की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 908

EN + हिं
GB The output of: mutex m; int x=0; thread t([&]{lock_guard lg(m); x=42;}); t.join(); cout<
IN का आउटपुट: म्यूटेक्स एम; int x=0; थ्रेड t([&]{lock_guard lg(m); x=42;}); टी.जुड़ें(); अदालत
42 42
Error गलती
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Thread safely sets x=42 under mutex; main reads 42.
व्याख्या (हिन्दी) थ्रेड सुरक्षित रूप से म्यूटेक्स के अंतर्गत x=42 सेट करता है; मुख्य पाठ 42.
🎯 Exam Perspective
UPSC, SSC, Banking और Police भर्ती जैसी परीक्षाओं में Data Structures and Algorithms से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें।

Question 909

EN + हिं Medium
GB Condition variable wait(lock, predicate) returns when:
IN कंडीशन वेरिएबल wait(lock, predicate) तब लौटता है जब:
Always immediately हमेशा तुरंत
Predicate returns true (spurious wakeups handled) विधेय सत्य लौटाता है (नकली वेकअप संभाला गया)
Mutex unlocks म्यूटेक्स अनलॉक हो जाता है
Thread signals थ्रेड सिग्नल
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) wait releases lock, waits for notification, rechecks predicate.
व्याख्या (हिन्दी) प्रतीक्षा लॉक जारी करती है, अधिसूचना की प्रतीक्षा करती है, विधेय की पुनः जाँच करती है।
🎯 Exam Perspective
अगर आप Railway, SSC, Banking और Defence परीक्षाओं की तैयारी कर रहे हैं, तो Data Structures and Algorithms का यह topic आपके लिए महत्वपूर्ण है — difficulty level "Medium"। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।

Question 910

EN + हिं Medium
GB std::call_once guarantees:
IN std::call_once गारंटी:
Function called multiple times फ़ंक्शन को कई बार कॉल किया गया
Function called exactly once across all threads फ़ंक्शन सभी थ्रेड्स में बिल्कुल एक बार कॉल किया जाता है
Per-thread call प्रति-थ्रेड कॉल
No guarantee कोई गारंटी नहीं
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Exactly one thread executes the function.
व्याख्या (हिन्दी) बिल्कुल एक थ्रेड फ़ंक्शन निष्पादित करता है।
🎯 Exam Perspective
Data Structures and Algorithms के इस प्रश्न को — difficulty level "Medium" कई प्रतियोगी परीक्षाओं जैसे SSC, Railway, Banking और State PCS में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 911

EN + हिं
GB What is the output: promise p; future f=p.get_future(); thread t([&p]{p.set_value(42);}); t.join(); cout<
IN आउटपुट क्या है: वादा पी; भविष्य f=p.get_future(); थ्रेड t([&p]{p.set_value(42);}); टी.जुड़ें(); अदालत
42 42
Error गलती
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Promise sets value; future.get() receives it.
व्याख्या (हिन्दी) वादा मूल्य निर्धारित करता है; Future.get() इसे प्राप्त करता है।
🎯 Exam Perspective
यह सवाल Data Structures and Algorithms category का है, और SSC CGL, IBPS, RRB और State-level परीक्षाओं के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 912

EN + हिं
GB The output of: auto f=async(launch::async,[]{return 42;}); cout<
IN का आउटपुट: auto f=async(launch::async,[]{return 42;}); अदालत
42 42
Error गलती
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) async runs lambda in thread; f.get() returns 42.
व्याख्या (हिन्दी) async थ्रेड में लैम्ब्डा चलाता है; f.get() 42 लौटाता है।
🎯 Exam Perspective
यह प्रश्न Data Structures and Algorithms की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर UPSC, SSC, Banking और Police भर्ती जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।

Question 913

EN + हिं
GB The output of: packaged_task pt([](){return 99;}); auto f=pt.get_future(); pt(); cout<
IN इसका आउटपुट: packaged_task pt([](){return 99;}); ऑटो f=pt.get_future(); पीटी(); अदालत
99 99
Error गलती
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) packaged_task wraps callable; invoke it; get result via future.
व्याख्या (हिन्दी) पैकेज्ड_टास्क कॉल करने योग्य रैप्स; इसका आह्वान करें; भविष्य के माध्यम से परिणाम प्राप्त करें।
🎯 Exam Perspective
Data Structures and Algorithms से जुड़ा यह सवाल उन students के लिए काम का है जो Railway, SSC, Banking और Defence परीक्षाओं की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 914

EN + हिं
GB What is the output: int x=5; auto f=[x=x*2]{return x;}; cout<
IN आउटपुट क्या है: int x=5; ऑटो f=[x=x*2]{रिटर्न x;}; अदालत
5 5
10 10
Error गलती
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Init capture x=x*2=10; lambda returns 10.
व्याख्या (हिन्दी) इनिट कैप्चर x=x*2=10; लैम्ब्डा रिटर्न 10.
🎯 Exam Perspective
SSC, Railway, Banking और State PCS जैसी परीक्षाओं में Data Structures and Algorithms से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें।

Question 915

EN + हिं Medium
GB Init captures in C++14 lambda [y=expr]:
IN C++14 लैम्ब्डा में Init कैप्चर [y=expr]:
Capture y by name y को नाम से पकड़ें
Capture and initialize new variable y with expr एक्सपीआर के साथ नए वेरिएबल y को कैप्चर और इनिशियलाइज़ करें
Copy capture कैप्चर कॉपी करें
Reference capture संदर्भ कैप्चर
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) [y = expr] creates new variable y inside lambda.
व्याख्या (हिन्दी) [y = expr] लैम्ब्डा के अंदर नया वेरिएबल y बनाता है।
🎯 Exam Perspective
अगर आप SSC CGL, IBPS, RRB और State-level परीक्षाओं की तैयारी कर रहे हैं, तो Data Structures and Algorithms का यह topic आपके लिए महत्वपूर्ण है — difficulty level "Medium"। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।