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
346
EN + हिं Medium
GB Stack remaining after push(5),push(3),pop(),push(7),push(1),pop(),pop()?
IN पुश(5),पुश(3),पॉप(),पुश(7),पुश(1),पॉप(),पॉप() के बाद बचा हुआ ढेर?
A
[5] [5]
B
[5,7] [5,7]
C
[3,7] [3,7]
D
[5,3] [5,3]
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) push5,push3,pop3,push7,push1,pop1,pop7 → [5].
व्याख्या (हिन्दी) पुश5, पुश3, पॉप3, पुश7, पुश1, पॉप1, पॉप7 → [5]।
347
EN + हिं Medium
GB dict.items() returns?
IN dict.items() रिटर्न?
A
Only keys केवल चाबियाँ
B
Only values केवल मूल्य
C
All key-value pairs as tuples सभी कुंजी-मूल्य जोड़े टुपल्स के रूप में
D
Count of items वस्तुओं की गिनती
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) dict.items() returns all key-value pairs as tuples.
व्याख्या (हिन्दी) dict.items() सभी कुंजी-मूल्य जोड़े को टुपल्स के रूप में लौटाता है।
348
EN + हिं Medium
GB Python set vs list membership check?
IN पायथन सेट बनाम सूची सदस्यता जांच?
A
Both O(1) दोनों O(1)
B
Both O(n) दोनों पर)
C
List O(n); Set O(1) average सूची ओ(एन); O(1) औसत सेट करें
D
List O(log n); Set O(1) सूची ओ(लॉग एन); सेट ओ(1)
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) List: O(n) scan; Set: O(1) average with hashing.
व्याख्या (हिन्दी) सूची: O(n) स्कैन; सेट: हेशिंग के साथ ओ(1) औसत।
349
EN + हिं Medium
GB Tuple vs list in Python?
IN पायथन में टुपल बनाम सूची?
A
Both mutable दोनों परिवर्तनशील
B
List immutable; Tuple mutable सूची अपरिवर्तनीय; टपल परिवर्तनशील
C
Tuple immutable and hashable; List mutable टपल अपरिवर्तनीय और धोने योग्य; सूची परिवर्तनशील
D
Both immutable दोनों अपरिवर्तनीय
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Tuple: immutable, hashable. List: mutable, not hashable.
व्याख्या (हिन्दी) टपल: अपरिवर्तनीय, धोने योग्य। सूची: परिवर्तनशील, धोने योग्य नहीं।
350
EN + हिं Medium
GB Kruskal algorithm finds MST by:
IN क्रुस्कल एल्गोरिदम एमएसटी को इसके द्वारा ढूंढता है:
A
Starting from vertex शिखर से शुरू
B
Sorting all edges and adding non-cycle-forming edges सभी किनारों को क्रमबद्ध करना और गैर-चक्र-गठन वाले किनारों को जोड़ना
C
BFS traversal बीएफएस ट्रैवर्सल
D
DFS traversal डीएफएस ट्रैवर्सल
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Kruskal: sort edges by weight, add if no cycle (use DSU).
व्याख्या (हिन्दी) क्रुस्कल: वजन के आधार पर किनारों को क्रमबद्ध करें, यदि कोई चक्र नहीं है तो जोड़ें (डीएसयू का उपयोग करें)।
351
EN + हिं Medium
GB Ford-Fulkerson algorithm solves:
IN फोर्ड-फ़ल्कर्सन एल्गोरिदम हल करता है:
A
Shortest path सबसे छोटा रास्ता
B
Maximum flow in a network किसी नेटवर्क में अधिकतम प्रवाह
C
Minimum spanning tree न्यूनतम फैलाव वाला पेड़
D
Topological sort टोपोलॉजिकल सॉर्ट
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Ford-Fulkerson finds max-flow using augmenting paths.
व्याख्या (हिन्दी) फोर्ड-फ़ल्कर्सन संवर्द्धन पथों का उपयोग करके अधिकतम-प्रवाह पाता है।
352
EN + हिं Hard
GB Which problem is solved by dynamic programming with O(nW) complexity?
IN O(nW) जटिलता के साथ गतिशील प्रोग्रामिंग द्वारा कौन सी समस्या हल की जाती है?
A
Sorting छंटाई
B
0/1 Knapsack problem 0/1 बस्ता समस्या
C
Graph coloring ग्राफ़ रंगना
D
Minimum spanning tree न्यूनतम फैलाव वाला पेड़
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 0/1 Knapsack: DP table of n items × W capacity.
व्याख्या (हिन्दी) 0/1 नैपसैक: एन आइटम × डब्ल्यू क्षमता की डीपी तालिका।
353
EN + हिं Medium
GB Longest Common Subsequence (LCS) of "ABCBDAB" and "BDCABA" has length:
IN "ABCBDAB" और "BDCABA" के सबसे लंबे सामान्य अनुवर्ती (LCS) की लंबाई है:
A
3 3
B
4 4
C
5 5
D
6 6
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) LCS = "BCBA" or "BDAB" = length 4.
व्याख्या (हिन्दी) एलसीएस = "बीसीबीए" या "बीडीएबी" = लंबाई 4।
354
EN + हिं Medium
GB Longest Increasing Subsequence (LIS) of {3,10,2,1,20} has length:
IN {3,10,2,1,20} की सबसे लंबी बढ़ती अनुवर्ती (एलआईएस) की लंबाई है:
A
2 2
B
3 3
C
4 4
D
5 5
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) LIS = {3,10,20} or {1,20} → max length 3.
व्याख्या (हिन्दी) एलआईएस = {3,10,20} या {1,20} → अधिकतम लंबाई 3।
355
EN + हिं Medium
GB Matrix Chain Multiplication uses which technique?
IN मैट्रिक्स श्रृंखला गुणन किस तकनीक का उपयोग करता है?
A
Greedy लालची
B
Dynamic Programming गतिशील प्रोग्रामिंग
C
Divide and Conquer फूट डालो और राज करो
D
Backtracking बैक ट्रैकिंग
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) MCM: DP to find optimal parenthesization.
व्याख्या (हिन्दी) एमसीएम: इष्टतम कोष्ठक खोजने के लिए डीपी।
356
EN + हिं Medium
GB Edit distance (Levenshtein distance) between "kitten" and "sitting" is:
IN "बिल्ली का बच्चा" और "बैठने" के बीच की दूरी (लेवेनशेटिन दूरी) संपादित करें:
A
3 3
B
4 4
C
5 5
D
6 6
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Edit distance is 3 (substitute k→s, substitute e→i, insert g).
व्याख्या (हिन्दी) संपादित दूरी 3 है (k→s प्रतिस्थापित करें, e→i प्रतिस्थापित करें, g डालें)।
357
EN + हिं Medium
GB Coin change problem (minimum coins) uses:
IN सिक्का परिवर्तन समस्या (न्यूनतम सिक्के) का उपयोग:
A
Greedy always हमेशा लालची
B
Dynamic Programming for general case सामान्य मामले के लिए गतिशील प्रोग्रामिंग
C
Only recursion केवल प्रत्यावर्तन
D
Brute force पाशविक बल
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) DP coin change: optimal substructure, overlapping subproblems.
व्याख्या (हिन्दी) डीपी सिक्का परिवर्तन: इष्टतम उपसंरचना, अतिव्यापी उपसमस्याएं।
358
EN + हिं Medium
GB KMP (Knuth-Morris-Pratt) algorithm efficiently solves:
IN KMP (नुथ-मॉरिस-प्रैट) एल्गोरिदम कुशलतापूर्वक हल करता है:
A
Sorting छंटाई
B
String pattern matching in O(n+m) O(n+m) में स्ट्रिंग पैटर्न का मिलान
C
Graph problems ग्राफ़ समस्याएँ
D
Dynamic programming गतिशील प्रोग्रामिंग
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) KMP: O(n+m) string search vs O(nm) naive.
व्याख्या (हिन्दी) KMP: O(n+m) स्ट्रिंग खोज बनाम O(nm) अनुभवहीन।
359
EN + हिं Medium
GB The failure function in KMP is used to:
IN KMP में विफलता फ़ंक्शन का उपयोग इसके लिए किया जाता है:
A
Handle failures विफलताओं को संभालें
B
Skip unnecessary comparisons by tracking longest proper prefix-suffix सबसे लंबे उचित उपसर्ग-प्रत्यय को ट्रैक करके अनावश्यक तुलना छोड़ें
C
Match patterns मिलान पैटर्न
D
Build suffix array प्रत्यय सरणी बनाएँ
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Failure function: longest proper prefix that is also suffix.
व्याख्या (हिन्दी) विफलता फ़ंक्शन: सबसे लंबा उचित उपसर्ग जो प्रत्यय भी है।
360
EN + हिं Medium
GB Rabin-Karp algorithm uses:
IN राबिन-कार्प एल्गोरिथ्म का उपयोग करता है:
A
Sorting छंटाई
B
Rolling hash for efficient multi-pattern search कुशल बहु-पैटर्न खोज के लिए रोलिंग हैश
C
Binary search द्विआधारी खोज
D
DP डी पी
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Rabin-Karp: hash-based string matching.
व्याख्या (हिन्दी) राबिन-कार्प: हैश-आधारित स्ट्रिंग मिलान।
346–360 of 1018