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
496
EN + हिं Medium
GB Tim sort (used in Python and Java) combines:
IN टिम सॉर्ट (पायथन और जावा में प्रयुक्त) जोड़ता है:
A
Only merge sort केवल मर्ज सॉर्ट करें
B
Insertion sort for small runs + merge sort छोटे रन के लिए इंसर्शन सॉर्ट + मर्ज सॉर्ट
C
Quick sort + heap sort त्वरित सॉर्ट + ढेर सॉर्ट
D
All four sorts सभी चार प्रकार
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) TimSort: insertion sort for small arrays + merge for merging.
व्याख्या (हिन्दी) टिमसॉर्ट: छोटे सरणियों के लिए सम्मिलन सॉर्ट + विलय के लिए मर्ज।
497
EN + हिं
GB The output of: int arr[]={5,2,8,1,9}; int n=5; for(int i=0;iarr[j+1]) swap(arr[j],arr[j+1]); cout<
IN इसका आउटपुट: int arr[]={5,2,8,1,9}; int n=5; for(int i=0;i
A
1 1
B
5 5
C
2 2
D
9 9
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Bubble sort: after sorting arr[0]=1.
व्याख्या (हिन्दी) बबल सॉर्ट: arr[0]=1 सॉर्ट करने के बाद।
498
EN + हिं
GB The output of: int arr[]={64,34,25,12,22,11,90}; // selection sort: for(int i=0;i<6;i++){int m=i; for(int j=i+1;j<7;j++) if(arr[j]
IN इसका आउटपुट: int arr[]={64,34,25,12,22,11,90}; // चयन प्रकार: for(int i=0;i
A
11 11
B
64 64
C
12 12
D
25 25
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Selection sort puts smallest first: 11.
व्याख्या (हिन्दी) चयन प्रकार सबसे छोटे को पहले रखता है: 11.
499
EN + हिं Medium
GB Binary search on sorted array {1,3,5,7,9,11,13}: how many comparisons to find 7?
IN क्रमबद्ध सरणी पर बाइनरी खोज {1,3,5,7,9,11,13}: 7 खोजने के लिए कितनी तुलनाएँ?
A
1 1
B
2 2
C
3 3
D
4 4
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) mid=7 at index 3; 3 comparisons: check mid=7 (found); at most 3 needed.
व्याख्या (हिन्दी) सूचकांक 3 पर मध्य=7; 3 तुलनाएँ: जाँच मध्य=7 (पाया गया); अधिकतम 3 की आवश्यकता है।
500
EN + हिं Easy
GB What is the maximum comparisons in binary search for n=1024 elements?
IN n=1024 तत्वों के लिए बाइनरी खोज में अधिकतम तुलना क्या है?
A
10 10
B
11 11
C
512 512
D
1024 1024
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) log2(1024)+1=10+1=11 worst case comparisons.
व्याख्या (हिन्दी) log2(1024)+1=10+1=11 सबसे खराब स्थिति तुलना।
501
EN + हिं Medium
GB Interpolation search works best when:
IN इंटरपोलेशन खोज सबसे अच्छा तब काम करती है जब:
A
Any data कोई भी डेटा
B
Data is uniformly distributed (better than binary search) डेटा समान रूप से वितरित किया जाता है (बाइनरी खोज से बेहतर)
C
Sorted data only केवल क्रमबद्ध डेटा
D
Random data यादृच्छिक डेटा
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Interpolation: O(log log n) for uniform distribution.
व्याख्या (हिन्दी) इंटरपोलेशन: समान वितरण के लिए ओ (लॉग लॉग एन)।
502
EN + हिं Medium
GB Exponential search is useful when:
IN घातीय खोज तब उपयोगी होती है जब:
A
Any array कोई भी सरणी
B
Array is sorted and size is unknown (infinite/very large) सरणी क्रमबद्ध है और आकार अज्ञात है (अनंत/बहुत बड़ा)
C
Small arrays छोटी सारणियाँ
D
Linked lists लिंक की गई सूचियाँ
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Exponential finds range then binary searches it.
व्याख्या (हिन्दी) एक्सपोनेंशियल रेंज ढूंढता है फिर बाइनरी उसे खोजता है।
503
EN + हिं Medium
GB Ternary search divides array into:
IN टर्नरी खोज सरणी को इसमें विभाजित करती है:
A
Two halves दो हिस्से
B
Three parts (finds max/min of unimodal function) तीन भाग (यूनिमॉडल फ़ंक्शन का अधिकतम/मिनट ज्ञात करता है)
C
Three equal parts for searching खोज के लिए तीन बराबर भाग
D
Random parts यादृच्छिक भाग
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Ternary search: for unimodal functions, O(log3(n)).
व्याख्या (हिन्दी) टर्नरी खोज: यूनिमॉडल फ़ंक्शंस के लिए, O(log3(n))।
504
EN + हिं Medium
GB Jump search works by:
IN जंप सर्च इनके द्वारा कार्य करता है:
A
Random jumps बेतरतीब छलांग
B
Jumping ahead by sqrt(n) steps then linear search back sqrt(n) चरणों से आगे बढ़ते हुए फिर रैखिक खोज
C
Binary then linear बाइनरी फिर रैखिक
D
Only forward केवल आगे
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Jump: O(sqrt(n)) time for sorted arrays.
व्याख्या (हिन्दी) कूदें: क्रमबद्ध सरणियों के लिए O(sqrt(n)) समय।
505
EN + हिं
GB The output of: int a[]={1,1,2,2,3}; cout<
IN इसका आउटपुट: int a[]={1,1,2,2,3}; अदालत
A
3 3
B
5 5
C
2 2
D
Error गलती
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) unique removes consecutive duplicates: {1,2,3,?,?}; 3 unique elements.
व्याख्या (हिन्दी) अद्वितीय लगातार डुप्लिकेट हटाता है: {1,2,3,?,?}; 3 अद्वितीय तत्व.
506
EN + हिं Easy
GB What is Big Theta of the best sort algorithm for general data?
IN सामान्य डेटा के लिए सर्वश्रेष्ठ सॉर्ट एल्गोरिदम का बिग थीटा क्या है?
A
O(n) पर)
B
O(n log n) ओ(एन लॉग एन)
C
O(n^2) ओ(एन^2)
D
O(log n) ओ(लॉग एन)
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) Lower bound for comparison sorts is Omega(n log n).
व्याख्या (हिन्दी) तुलना प्रकारों के लिए निचली सीमा ओमेगा (एन लॉग एन) है।
507
EN + हिं
GB The output of: int n; cin>>n; cout<<(n%15==0?"FizzBuzz":n%3==0?"Fizz":n%5==0?"Buzz":to_string(n)); with n=15:
IN का आउटपुट: int n; सीन>>एन; अदालत
A
Fizz सीटी
B
Buzz भनभनाना
C
FizzBuzz फ़िज़बज़
D
15 15
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 15%15==0 is true; outputs FizzBuzz.
व्याख्या (हिन्दी) 15%15==0 सत्य है; फ़िज़बज़ आउटपुट करता है।
508
EN + हिं Medium
GB FizzBuzz for n=9 outputs:
IN n=9 आउटपुट के लिए FizzBuzz:
A
9 9
B
Fizz सीटी
C
Buzz भनभनाना
D
FizzBuzz फ़िज़बज़
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 9%3==0 but 9%5!=0; outputs Fizz.
व्याख्या (हिन्दी) 9%3==0 लेकिन 9%5!=0; फ़िज़ आउटपुट करता है।
509
EN + हिं Medium
GB FizzBuzz for n=10 outputs:
IN n=10 आउटपुट के लिए FizzBuzz:
A
10 10
B
Fizz सीटी
C
Buzz भनभनाना
D
FizzBuzz फ़िज़बज़
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 10%5==0 but 10%3!=0; outputs Buzz.
व्याख्या (हिन्दी) 10%5==0 लेकिन 10%3!=0; बज़ आउटपुट करता है।
510
EN + हिं Medium
GB FizzBuzz for n=7 outputs:
IN n=7 आउटपुट के लिए FizzBuzz:
A
7 7
B
Fizz सीटी
C
Buzz भनभनाना
D
FizzBuzz फ़िज़बज़
✅ Correct Answer:
💡 Explanation / व्याख्या
Explanation (English) 7%3!=0 and 7%5!=0; outputs 7.
व्याख्या (हिन्दी) 7%3!=0 और 7%5!=0; आउटपुट 7.
496–510 of 1018