FliQi Education App Download
विषय-वार प्रश्न-बैंक

DSA — प्रश्न-बैंक

654 जाँचे हुए प्रश्न · 6 topics

Topics

और: Linked list · Arrays · Introduction to Algorithms (कम प्रश्न — app में)

किन परीक्षाओं में

नमूना प्रश्न

भाषा
प्रश्न 1उत्तर + हल Introduction to Data Structures & Algorithms
Pre-order traversal का सही क्रम क्या है?
What is the correct order of pre-order traversal?
  1. ALeft, Root, Right
  2. BRoot, Left, Right
  3. CLeft, Right, Root
  4. DRight, Root, Left

सही उत्तर / Answer: (B)

हल / Solution
Pre-order में पहले मूल (root) देखा जाता है, फिर पूरा बायाँ उपवृक्ष, और अंत में पूरा दायाँ उपवृक्ष — संक्षेप में यही क्रम node, बायाँ, दायाँ कहलाता है। इसी कारण pre-order क्रम का पहला अवयव हमेशा वृक्ष का मूल होता है, और हर उपवृक्ष के भीतर भी यही क्रम दोहराया जाता है। बायाँ, मूल, दायाँ वाला क्रम in-order है और बायाँ, दायाँ, मूल वाला post-order; चौथा विकल्प किसी मानक क्रम का नाम ही नहीं।
Pre-order visits the root first, then the whole left subtree, and the whole right subtree last; in short, node, left, right. That is why the first element of a pre-order sequence is always the root of the tree, and the same order repeats inside every subtree. Left, root, right is in-order, and left, right, root is post-order, while the fourth option matches no standard traversal.
प्रश्न 2उत्तर + हल Tree
फुल बाइनरी ट्री में यदि आंतरिक नोड की संख्या I हो, तो लीफ़ L कितनी होंगी?
In a full binary tree, if the number of internal nodes is I, then the number of leaves L is
  1. AL = 2I
  2. BL = I + 1
  3. CL = I - 1
  4. DL = 2I - 1

सही उत्तर / Answer: (B)

हल / Solution
फुल बाइनरी ट्री में हर आंतरिक नोड के ठीक दो बच्चे होते हैं। इसलिए I आंतरिक नोड से कुल 2I किनारे निकलते हैं। किसी भी ट्री में नोड किनारों से एक ज़्यादा होते हैं, यानी I + L = 2I + 1। इसे हल कीजिए तो L = I + 1 मिलता है। जाँच के लिए 3 आंतरिक नोड लीजिए — वहाँ 4 लीफ़ आती हैं। यही संबंध हफ़मैन ट्री और डिसीज़न ट्री में बार-बार काम आता है।
In a full binary tree every internal node has exactly two children, so I internal nodes produce 2I edges in all. Any tree has one more node than it has edges, which gives I + L = 2I + 1. Solving this leaves L = I + 1, so there is always one leaf more than the internal nodes. Check it with 3 internal nodes, which give 4 leaves. The same relation shows up in Huffman trees and decision trees.
प्रश्न 3उत्तर + हल Stack
यदि किसी स्टैक का आकार पाँच है और उसमें पहले से पाँच एलिमेंट भरे हैं, तब एक और एलिमेंट PUSH करने पर स्टैक की स्थिति क्या बनेगी?
If a user PUSHes one more element into a stack that already holds five elements and whose size is five, then the stack becomes
  1. Aओवरफ़्लो (overflow)overflow
  2. Bअंडरफ़्लो (underflow)underflow
  3. Cयूज़र फ़्लो (user flow)user flow
  4. Dक्रैश (crash)crash

सही उत्तर / Answer: (A)

हल / Solution
ऐरे से बने स्टैक की क्षमता पहले से तय रहती है। यहाँ आकार पाँच है और पाँचों जगह भरी हैं, इसलिए छठा एलिमेंट रखने की जगह बची ही नहीं। इस स्थिति को स्टैक ओवरफ़्लो कहते हैं और PUSH से पहले यही जाँच की जाती है। अंडरफ़्लो इसका उलटा है, जो ख़ाली स्टैक पर POP करने से बनता है। 'यूज़र फ़्लो' कोई तकनीकी शब्द नहीं है, और क्रैश इसका नतीजा हो सकता है, नाम नहीं।
A stack built on an array has a fixed capacity. Here the size is five and all five slots are already filled, so no room is left for a sixth element. This state is called stack overflow, and a program checks for it before every PUSH. Underflow is the opposite case and arises when POP is used on an empty stack. User flow is not a technical term, and a crash is a result, not a name.
प्रश्न 4उत्तर + हल Sorting
ऐरे में मान ढूँढ़ने के लिए बाइनरी सर्च एल्गोरिथम में निम्नलिखित में से कौन सा कथन उपयोग होता है?
Which of the following statements is used in the binary search algorithm to find value of the array?
  1. Aमिडिल इंडेक्स = (स्टार्ट इंडेक्स + स्टॉप इंडेक्स)/2Middle Index = (Start Index + Stop Index)/2
  2. Bमिडिल इंडेक्स = (स्टार्ट इंडेक्स − स्टॉप इंडेक्स)/2Middle Index = (Start Index − Stop Index)/2
  3. Cमिडिल इंडेक्स = (स्टार्ट इंडेक्स)/2 + स्टॉप इंडेक्सMiddle Index = (Start Index)/2 + Stop Index
  4. Dमिडिल इंडेक्स = (स्टार्ट इंडेक्स)/2 − स्टॉप इंडेक्सMiddle Index = (Start Index)/2 − Stop Index

सही उत्तर / Answer: (A)

हल / Solution
बाइनरी सर्च को हर क़दम पर बीच की जगह चाहिए, और दो सिरों के बीच का स्थान उनका औसत होता है — इसलिए मिडिल इंडेक्स = (स्टार्ट + स्टॉप)/2। जैसे स्टार्ट 0 और स्टॉप 8 हो तो मिडिल 4 आता है, जो ठीक बीच है। अंतर वाला सूत्र (स्टार्ट − स्टॉप)/2 ऋणात्मक मान दे देता है। बाक़ी दो सूत्र स्टॉप इंडेक्स को जोड़ या घटा देते हैं, इसलिए उनका नतीजा सूची की सीमा से भी बाहर जा सकता है।
Binary search needs the middle position at every step, and the place halfway between two ends is simply their average, so the middle index equals start plus stop, divided by two. With start 0 and stop 8 the middle comes to 4, which is exactly in the middle. The difference form would give a negative value. The last two forms add or subtract the stop index, so their result can even fall outside the bounds of the list.
प्रश्न 5उत्तर + हल Graph
n शीर्षों और e किनारों वाले अदिशात्मक (undirected) graph G में सभी शीर्षों की डिग्री का योग क्या होता है?
For an undirected graph G with n vertices and e edges, the sum of the degrees of all vertices is
  1. Ane
  2. B2n
  3. C2e
  4. Den

सही उत्तर / Answer: (C)

हल / Solution
हर किनारा (edge) ठीक दो शीर्षों को जोड़ता है, इसलिए वह दोनों शीर्षों की डिग्री में एक-एक बार गिना जाता है। इसी से सभी डिग्री का योग किनारों का दोगुना, यानी 2e हो जाता है — इसे हस्तमिलाप प्रमेयिका (handshaking lemma) कहते हैं। इसका एक नतीजा यह है कि विषम डिग्री वाले शीर्षों की संख्या हमेशा सम होती है। जाँच: n शीर्षों वाले ट्री में किनारे n − 1 होते हैं, तो डिग्री का योग 2(n − 1) निकलता है।
Every edge joins exactly two vertices, so it is counted once in the degree of each of them. That makes the sum of all degrees twice the edge count, that is 2e, a fact known as the handshaking lemma. One consequence is that the number of vertices of odd degree is always even. Check it on a tree with n vertices, which has n minus 1 edges, so the degrees there add up to 2 times n minus 1.
प्रश्न 6उत्तर + हल Queue
आउटपुट-रिस्ट्रिक्टेड डेक दोनों सिरों पर ............ की अनुमति देता है और केवल एक सिरे पर ............ की।
An output-restricted dequeue allows ........... at both ends and ..... at only one end.
  1. Aडिलीशन, इंसर्शनdeletion, insertion
  2. Bइंसर्शन, डिलीशनinsertion, deletion
  3. Cपुश, पॉप (PUSH, POP)PUSH, POP
  4. Dकेवल इंसर्शन की अनुमति देता है, डिलीशन की नहींAllows only insertion, not deletion

सही उत्तर / Answer: (B)

हल / Solution
नाम में जिस क्रिया पर रोक लगी है, वही एक सिरे तक सीमित रहती है। आउटपुट-रिस्ट्रिक्टेड डेक में आउटपुट यानी डिलीशन पर रोक है, इसलिए एलिमेंट निकलेगा केवल एक सिरे से, जबकि डालना दोनों सिरों पर चलेगा। पहला विकल्प इसका उलटा कहता है और वह इनपुट-रिस्ट्रिक्टेड डेक का नियम है। पुश और पॉप स्टैक के ऑपरेशन हैं। चौथा विकल्प कहता है कि डिलीशन होता ही नहीं, जो किसी भी डेक के लिए ग़लत है।
Whichever operation the name restricts is the one limited to a single end. In an output restricted deque the output, that is deletion, is restricted, so elements can leave from one end only, while insertion is allowed at both ends. The first option states the reverse and actually describes an input restricted deque. PUSH and POP are stack operations. The fourth option claims that deletion never happens, which is wrong for any deque.
प्रश्न 7उत्तर + हल
निम्नलिखित में से कौन डबली लिंक्ड लिस्ट का लाभ नहीं है?
Which of the following is not an advantage of a doubly linked list?
  1. Aसरल इंसर्शन और डिलीशनSimple insertion and deletion
  2. Bकुशल मेमोरी उपयोगEfficient memory utilisation
  3. Cद्वि-दिशात्मक ट्रैवर्सलBi-directional traversal
  4. Dअधिक मेमोरी स्थान की आवश्यकताMore memory space requirement

सही उत्तर / Answer: (D)

हल / Solution
डबली लिंक्ड लिस्ट के हर नोड में prev और next, यानी दो पॉइंटर रखने पड़ते हैं, इसलिए वह सिंगली लिस्ट से ज़्यादा मेमोरी खाती है। यह उसकी कमी है, लाभ नहीं, इसलिए चौथा विकल्प ही उत्तर है। बाक़ी तीनों असली लाभ हैं: पिछली कड़ी मौजूद होने से किसी नोड को हटाना आसान हो जाता है, आगे-पीछे दोनों दिशाओं में चला जा सकता है, और जगह चलते समय माँगी जाती है इसलिए ऐरे जैसी बँधी सीमा नहीं रहती।
Every node of a doubly linked list has to keep two pointers, prev and next, so it uses more memory than a singly linked list. That is a drawback and not an advantage, which makes option 4 the answer. The other three are genuine advantages: the backward link makes deleting a node easy, traversal is possible in both directions, and space is taken at run time so there is no fixed limit as in an array.
प्रश्न 8उत्तर + हल
ऐरे के अलग-अलग अवयवों को ऐरे के नाम के साथ क्या बताकर पढ़ा जाता है?
The individual elements of an array are accessed by specifying the array name with their
  1. Aइंडेक्स (index)Index
  2. Bडेटा मान (data value)Data value
  3. Cसबस्क्रिप्ट (subscript)Subscript
  4. Dपहला और तीसरा, दोनोंBoth (a) and (c)

सही उत्तर / Answer: (D)

हल / Solution
ऐरे के अवयव तक पहुँचने के लिए नाम के साथ जो अंक लिखा जाता है, उसे इंडेक्स (index) और सबस्क्रिप्ट (subscript), दोनों नामों से पुकारा जाता है; ये एक ही चीज़ के दो नाम हैं। जैसे A[5] में 5 ही इंडेक्स है और वही सबस्क्रिप्ट। इसलिए अकेला पहला या अकेला तीसरा विकल्प अधूरा रहता है और दोनों वाला चौथा विकल्प सही है। डेटा मान तो वह सामग्री है जो खाने में रखी है, पहुँचने का साधन नहीं।
The number written after the array name to reach an element is called both an index and a subscript; these are two names for the same thing. In A[5] the 5 is the index and equally the subscript. So option 1 alone or option 3 alone is incomplete, and the correct choice is both of them, option 4. A data value is the content stored in a cell, not the means of reaching it.
प्रश्न 9उत्तर + हल
Fractional knapsack problem को और किस नाम से जाना जाता है?
The fractional knapsack problem is also known as:
  1. A0/1 नैपसैक problem0/1 knapsack problem
  2. Bकंटीन्युअस नैपसैक (continuous knapsack) problemContinuous knapsack problem
  3. Cबाउंडेड नैपसैक (bounded knapsack) problemBounded knapsack problem
  4. Dनॉन-कंटीन्युअस नैपसैक problemNon continuous knapsack problem

सही उत्तर / Answer: (B)

हल / Solution
Fractional knapsack में हर वस्तु विभाज्य मानी जाती है, यानी उसका कोई भी अंश (fraction) उठाया जा सकता है, पूरा लेना ज़रूरी नहीं। चूँकि ली गई मात्रा 0 से 1 के बीच कोई भी हो सकती है, यानी निरंतर (continuous) है, इसी से नाम Continuous knapsack problem पड़ा। इसका उलटा रूप 0/1 नैपसैक है, जहाँ वस्तु पूरी लेनी होती है या छोड़नी होती है। बाउंडेड नैपसैक में हर वस्तु की गिनती पर सीमा होती है।
In the fractional knapsack problem every item is treated as divisible, so any fraction of an item may be taken instead of the whole item. Because the amount chosen can be any value between 0 and 1, that is, continuous, the problem is also called the continuous knapsack problem. The 0/1 knapsack is the opposite, where an item is taken whole or left out. In the bounded version each item has a limited count.
DSA का पूरा प्रश्न-बैंकहर topic के सारे प्रश्न, हल और अभ्यास — FliQi Question Bank app में