Data Structures and Algorithms — MCQ Practice

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

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

Question 226

EN + हिं Medium
GB Law of Demeter (Principle of Least Knowledge) says:
IN डेमेटर का नियम (न्यूनतम ज्ञान का सिद्धांत) कहता है:
Talk to everyone सबसे बात करो
Object should only talk to immediate friends (not friends of friends) वस्तु को केवल निकटतम मित्रों से बात करनी चाहिए (दोस्तों के मित्रों से नहीं)
Share all data सभी डेटा साझा करें
Use global variables वैश्विक चर का प्रयोग करें
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) obj.getA().getB().doC() violates LoD.
व्याख्या (हिन्दी) obj.getA().getB().doC() LoD का उल्लंघन करता है।
🎯 Exam Perspective
Data Structures and Algorithms ("Introduction to DSA" sub-topic) के इस प्रश्न को — difficulty level "Medium" कई प्रतियोगी परीक्षाओं जैसे SSC CGL, IBPS, RRB और State-level परीक्षाओं में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 227

EN + हिं Medium
GB Which is an anti-pattern?
IN कौन सा एक विरोधी पैटर्न है?
Design pattern डिज़ाइन पैटर्न
Singleton overuse, God class, Copy-paste programming सिंगलटन अति प्रयोग, गॉड क्लास, कॉपी-पेस्ट प्रोग्रामिंग
Inheritance विरासत
Encapsulation कैप्सूलीकरण
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Anti-patterns are commonly used but counterproductive solutions.
व्याख्या (हिन्दी) आमतौर पर विरोधी पैटर्न का उपयोग किया जाता है लेकिन प्रतिउत्पादक समाधान।
🎯 Exam Perspective
यह सवाल Data Structures and Algorithms ("Introduction to DSA" sub-topic) category का है — difficulty level "Medium", और UPSC, SSC, Banking और Police भर्ती के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 228

EN + हिं
GB The output of: class C{int x; public: C():x(0){} C(int x):x(x){} void print(){cout<
IN का आउटपुट: वर्ग C{int x; सार्वजनिक: C():x(0){} C(int x):x(x){} void print(){cout
05 05
50 50
00 00
55 55
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) c1 uses default ctor (x=0); c2 uses parameterized (x=5).
व्याख्या (हिन्दी) c1 डिफ़ॉल्ट ctor (x=0) का उपयोग करता है; c2 पैरामीटरयुक्त (x=5) का उपयोग करता है।
🎯 Exam Perspective
यह प्रश्न Data Structures and Algorithms ("Introduction to DSA" sub-topic) की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर Railway, SSC, Banking और Defence परीक्षाओं जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।

Question 229

EN + हिं
GB The output of: class A{public:int x; A(int x):x(x){}}; A a(5); cout<
IN का आउटपुट: क्लास ए {सार्वजनिक: int x; A(int x):x(x){}}; ए ए(5); अदालत
Error गलती
5 5
Undefined अपरिभाषित
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) x is public; direct access gives x=5.
व्याख्या (हिन्दी) x सार्वजनिक है; सीधी पहुंच x=5 देती है।
🎯 Exam Perspective
Data Structures and Algorithms ("Introduction to DSA" sub-topic) से जुड़ा यह सवाल उन students के लिए काम का है जो SSC, Railway, Banking और State PCS की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 230

EN + हिं
GB The output of: int f(int n){return n<=1 ? 1 : n*f(n-1);} cout<
IN इसका आउटपुट: int f(int n){return n
120 120
24 24
5 5
Error गलती
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 5! = 5*4*3*2*1 = 120.
व्याख्या (हिन्दी) 5! = 5*4*3*2*1 = 120.
🎯 Exam Perspective
SSC CGL, IBPS, RRB और State-level परीक्षाओं जैसी परीक्षाओं में Data Structures and Algorithms ("Introduction to DSA" sub-topic) से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें।

Question 231

EN + हिं
GB The output of: int f(int n){return n<=1 ? n : f(n-1)+f(n-2);} cout<
IN इसका आउटपुट: int f(int n){return n
13 13
21 21
8 8
34 34
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Fibonacci: F(7)=13.
व्याख्या (हिन्दी) फाइबोनैचि: एफ(7)=13.
🎯 Exam Perspective
अगर आप UPSC, SSC, Banking और Police भर्ती की तैयारी कर रहे हैं, तो Data Structures and Algorithms ("Introduction to DSA" sub-topic) का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।

Question 232

EN + हिं
GB The output of: int gcd(int a,int b){return b==0?a:gcd(b,a%b);} cout<
IN इसका आउटपुट: int gcd(int a,int b){return b==0?a:gcd(b,a%b);} cout
6 6
3 3
9 9
18 18
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) GCD(18)=GCD(12)=GCD(6)=GCD(0)=6.
व्याख्या (हिन्दी) जीसीडी(18)=जीसीडी(12)=जीसीडी(6)=जीसीडी(0)=6.
🎯 Exam Perspective
Data Structures and Algorithms ("Introduction to DSA" sub-topic) के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे Railway, SSC, Banking और Defence परीक्षाओं में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 233

EN + हिं
GB The output of: int power(int b,int e){return e==0?1:b*power(b,e-1);} cout<
IN इसका आउटपुट: int power(int b,int e){return e==0?1:b*power(b,e-1);} cout
128 128
256 256
64 64
512 512
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 2^8=256.
व्याख्या (हिन्दी) 2^8=256.
🎯 Exam Perspective
यह सवाल Data Structures and Algorithms ("Introduction to DSA" sub-topic) category का है, और SSC, Railway, Banking और State PCS के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 234

EN + हिं Medium
GB Fast power (exponentiation by squaring) computes a^n in:
IN तीव्र शक्ति (वर्गीकरण द्वारा घातांक) a^n की गणना करता है:
O(n) पर)
O(log n) ओ(लॉग एन)
O(n^2) ओ(एन^2)
O(1) हे(1)
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Square the base for even exponents: O(log n).
व्याख्या (हिन्दी) सम घातांक के लिए आधार का वर्ग करें: O(लॉग एन)।
🎯 Exam Perspective
यह प्रश्न Data Structures and Algorithms ("Introduction to DSA" sub-topic) की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है — difficulty level "Medium"। इस तरह के प्रश्न अक्सर SSC CGL, IBPS, RRB और State-level परीक्षाओं जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।

Question 235

EN + हिं
GB The output of: int arr[]={5,3,8,1,9,2}; sort(arr,arr+6); cout<
IN इसका आउटपुट: int arr[]={5,3,8,1,9,2}; क्रमबद्ध करें (arr,arr+6); अदालत
1 9 1 9
5 2 5 2
9 1 9 1
3 8 3 8
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Sorted ascending: arr[0]=1, arr[5]=9.
व्याख्या (हिन्दी) आरोही क्रम में क्रमबद्ध: arr[0]=1, arr[5]=9।
🎯 Exam Perspective
Data Structures and Algorithms ("Introduction to DSA" sub-topic) से जुड़ा यह सवाल उन students के लिए काम का है जो UPSC, SSC, Banking और Police भर्ती की तैयारी कर रहे हैं। बेहतर होगा कि explanation पढ़कर concept clear करें, ताकि exam में similar प्रश्न आने पर confusion न हो।

Question 236

EN + हिं
GB The output of: int arr[]={1,2,3,4,5}; cout<<*max_element(arr,arr+5)<<" "<<*min_element(arr,arr+5);
IN इसका आउटपुट: int arr[]={1,2,3,4,5}; अदालत
5 1 5 1
1 5 1 5
3 1 3 1
Error गलती
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Max=5, Min=1.
व्याख्या (हिन्दी) अधिकतम=5, न्यूनतम=1.
🎯 Exam Perspective
Railway, SSC, Banking और Defence परीक्षाओं जैसी परीक्षाओं में Data Structures and Algorithms ("Introduction to DSA" sub-topic) से सवाल अक्सर पूछे जाते हैं। इसलिए सिर्फ answer रटने के बजाय, नीचे दी गई explanation को ध्यान से पढ़ें और concept समझें।

Question 237

EN + हिं
GB The output of: string s="Hello World"; transform(s.begin(),s.end(),s.begin(),toupper); cout<
IN इसका आउटपुट: स्ट्रिंग s='हैलो वर्ल्ड'; परिवर्तन(s.begin(),s.end(),s.begin(),toupper); अदालत
hello world हैलो वर्ल्ड
HELLO WORLD हैलो वर्ल्ड
Hello World हैलो वर्ल्ड
Error गलती
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) toupper converts each char to uppercase.
व्याख्या (हिन्दी) टॉपर प्रत्येक अक्षर को अपरकेस में परिवर्तित करता है।
🎯 Exam Perspective
अगर आप SSC, Railway, Banking और State PCS की तैयारी कर रहे हैं, तो Data Structures and Algorithms ("Introduction to DSA" sub-topic) का यह topic आपके लिए महत्वपूर्ण है। Exam में accuracy बढ़ाने के लिए हर सवाल की explanation जरूर पढ़ें।

Question 238

EN + हिं
GB The output of: vector v={1,2,3}; v.resize(5); cout<
IN का आउटपुट: वेक्टर v={1,2,3}; v.आकार बदलें(5); अदालत
Error गलती
3 3
Garbage कचरा
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) resize(5) adds 2 zero-initialized elements.
व्याख्या (हिन्दी) आकार बदलें (5) 2 शून्य-प्रारंभिक तत्व जोड़ता है।
🎯 Exam Perspective
Data Structures and Algorithms ("Introduction to DSA" sub-topic) के इस प्रश्न को कई प्रतियोगी परीक्षाओं जैसे SSC CGL, IBPS, RRB और State-level परीक्षाओं में repeat होते देखा गया है। Concept clarity के लिए explanation section जरूर पढ़ें।

Question 239

EN + हिं
GB The output of: string s="abcabc"; cout<
IN इसका आउटपुट: स्ट्रिंग s='abcabc'; अदालत
1 1
2 2
3 3
Error गलती
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Two a characters in "abcabc".
व्याख्या (हिन्दी) "एबीसीएबीसी" में दो अक्षर।
🎯 Exam Perspective
यह सवाल Data Structures and Algorithms ("Introduction to DSA" sub-topic) category का है, और UPSC, SSC, Banking और Police भर्ती के exam pattern में इस तरह के questions common हैं। Answer choose करने के बाद दिया गया explanation जरूर पढ़ें।

Question 240

EN + हिं
GB The output of: cout<2)<<" "<<(2>3);
IN का आउटपुट: कॉउट
1 0 1 0
true false सच्चा झूठ
True False सच्चा झूठ
Error गलती
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) boolalpha mode: true/false words.
व्याख्या (हिन्दी) बूलल्फा मोड: सही/गलत शब्द।
🎯 Exam Perspective
यह प्रश्न Data Structures and Algorithms ("Introduction to DSA" sub-topic) की तैयारी करने वाले अभ्यर्थियों के लिए उपयोगी है। इस तरह के प्रश्न अक्सर Railway, SSC, Banking और Defence परीक्षाओं जैसी परीक्षाओं में पूछे जाते रहे हैं, इसलिए concept और explanation दोनों को ध्यान से समझें, सिर्फ उत्तर याद न करें।