FliQi Education App Download
प्रश्न-बैंक · DSA

Introduction to Data Structures & Algorithms — प्रश्न और उत्तर

DSA · 436 जाँचे हुए (verified) प्रश्न

  • 436 जाँचे हुए प्रश्न
  • हिंदी + English

पहले 10 प्रश्नों के उत्तर और हल यहीं खुले हैं; बाक़ी 20 के उत्तर और हल FliQi Question Bank app में।

भाषा
प्रश्न 1उत्तर + हल
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उत्तर + हल
Post-order traversal में सबसे अंत में कौन-सा node देखा जाता है?
In post-order traversal, which node is visited last?
  1. Aसबसे बाएँ वाला पत्ता (leftmost leaf)Leftmost leaf
  2. Bमूल (root)Root
  3. Cसबसे दाएँ वाला पत्ता (rightmost leaf)Rightmost leaf
  4. Dसबसे पहले डाला गया nodeFirst inserted node

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

हल / Solution
Post-order का क्रम है बायाँ, दायाँ, फिर मूल (root)। इसलिए पहले पूरा बायाँ उपवृक्ष, फिर पूरा दायाँ उपवृक्ष देखा जाता है और सबसे अंत में पूरे वृक्ष का मूल आता है। यही गुण वृक्ष दोबारा बनाने में काम आता है: post-order क्रम का आख़िरी अवयव ही मूल होता है, जिससे in-order की मदद से बाएँ-दाएँ भाग अलग हो जाते हैं। पत्ते बीच में निपट जाते हैं, इसलिए पहला या तीसरा विकल्प सही नहीं।
Post-order visits the left subtree, then the right subtree, and the root last. So the whole left side is finished first, the whole right side next, and the root of the entire tree comes at the very end. This property is used when rebuilding a tree: the last element of a post-order sequence is the root, and in-order then separates the left and right parts. The leaves are finished in between, so the leaf options are wrong.
प्रश्न 3उत्तर + हल
Level-order traversal किस खोज-दृष्टिकोण पर आधारित है?
Level-order traversal is based on which search approach?
  1. Aगहराई-पहले खोज (depth first search)Depth First Search
  2. Bचौड़ाई-पहले खोज (breadth first search)Breadth First Search
  3. Cद्विआधारी खोज (binary search)Binary Search
  4. Dरैखिक खोज (linear search)Linear Search

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

हल / Solution
Level-order क्रम में वृक्ष को ऊपर से नीचे देखा जाता है — एक स्तर पूरा करके अगला स्तर, और हर स्तर में बाएँ से दाएँ। यही चौड़ाई-पहले खोज (breadth first search) का तरीक़ा है, इसलिए level-order उसी पर टिका है। इसे लागू करने के लिए क़तार (queue) रखी जाती है: जिस node को देखा, उसकी संतानें क़तार में जोड़ दी जाती हैं। In-order, pre-order और post-order गहराई-पहले चलते हैं, और बाक़ी दो विकल्पों का यहाँ कोई काम नहीं।
Level-order traversal reads the tree from the top downwards, finishing one level before moving to the next and going left to right within a level. That is exactly how breadth first search works, so level-order rests on it. A queue is used to implement it: when a node is visited, its children are pushed into the queue. In-order, pre-order and post-order are depth first, and the other two options play no part.
प्रश्न 4उत्तर + हल
कौन-सा graph traversal binary tree के level-order traversal से सबसे मिलता-जुलता है?
Which graph traversal closely imitates level-order traversal of a binary tree?
  1. Aगहराई-पहले खोज (depth first search)Depth First Search
  2. Bचौड़ाई-पहले खोज (breadth first search)Breadth First Search
  3. Cगहराई और चौड़ाई-पहले खोज, दोनोंDepth & Breadth First Search
  4. Dद्विआधारी खोज (binary search)Binary Search

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

हल / Solution
वृक्ष का level-order क्रम node को स्तर-दर-स्तर देखता है, और ग्राफ़ में यही बरताव चौड़ाई-पहले खोज (breadth first search) का है। वह किसी एक node से चलकर पहले उसके सारे सीधे पड़ोसी देखती है, फिर उनके पड़ोसी — यानी दूरी के बढ़ते क्रम में। दोनों में क़तार (queue) लगती है, इसीलिए क्रम एक जैसा बनता है। गहराई-पहले खोज एक शाखा में नीचे उतरती है, जो pre-order जैसी है, level-order जैसी नहीं।
Level-order traversal of a tree visits nodes level by level, and in a graph the same behaviour belongs to breadth first search. Starting from one node it first visits all of its direct neighbours, then their neighbours, that is, in increasing order of distance. Both use a queue, which is why the two orders match. Depth first search descends along one branch, which resembles pre-order, not level-order.
प्रश्न 5उत्तर + हल
3 node के साथ, post-order क्रम N, M, L देने वाले कितने द्विआधारी वृक्ष (binary trees) बनाए जा सकते हैं?
How many binary trees can be created with 3 nodes giving sequence N, M, L in post-order?
  1. A15
  2. B3
  3. C5
  4. D8

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

हल / Solution
n भिन्न node से बनने वाले द्विआधारी वृक्षों (binary trees) की संख्या कातालान संख्या (Catalan number) से मिलती है: C(n) = (2n)! / ((n+1)! × n!)। n = 3 रखिए तो C(3) = 720 / (24 × 6) = 5 आता है। यानी दिए गए post-order क्रम के साथ पाँच भिन्न आकार संभव हैं, क्योंकि node के मान तय होने पर भी उनका आपसी parent-child ढाँचा कई रूप ले सकता है। इसलिए सही उत्तर 5 है।
The number of different binary tree shapes on n distinct nodes is given by the Catalan number C(n) = (2n)! / ((n+1)! n!). Putting n = 3 gives C(3) = 720 / (24 x 6) = 5. So with the given post-order sequence exactly five shapes are possible, because fixing the node values still leaves several parent-child arrangements. The correct answer is therefore 5, and not 3, 8 or 15.
प्रश्न 6उत्तर + हल
कौन-से दो traversals मिलकर किसी binary tree को uniquely बना सकते हैं?
Which pair of traversals can build a binary tree uniquely?
  1. APost-order और pre-orderPost-order and pre-order
  2. BPost-order और in-orderPost-order and in-order
  3. CPost-order और level-orderPost-order and level-order
  4. DLevel-order और pre-orderLevel-order and pre-order

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

हल / Solution
किसी द्विआधारी वृक्ष (binary tree) को एक ही रूप में दोबारा बनाने के लिए in-order क्रम चाहिए, क्योंकि वही बताता है कि मूल के बाएँ कौन है और दाएँ कौन। Post-order से मूल मिल जाता है और in-order उसे दो भागों में काट देता है, सो यह जोड़ी वृक्ष पूरी तरह तय कर देती है। अकेले pre-order और post-order से काम नहीं चलता — किसी node की एक ही संतान हो तो वह बाईं है या दाईं, पता नहीं चलता।
To rebuild a binary tree in exactly one way you need the in-order sequence, because only it tells which nodes lie to the left of a root and which lie to the right. Post-order hands you the root, and in-order then cuts the rest into two halves, so this pair fixes the tree completely. Pre-order with post-order is not enough: when a node has a single child, you cannot tell whether it is the left or the right one.
प्रश्न 7उत्तर + हल
किसी binary tree का post-order क्रम O P Q R S T है, तो संभावित pre-order कौन-सा होगा?
Post-order of a binary tree is O P Q R S T. Possible pre-order will be?
  1. AT Q R S O P
  2. BT O Q R P S
  3. CT Q O P S R
  4. DT Q O S P R

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

हल / Solution
Post-order में मूल (root) सबसे आख़िर में आता है, इसलिए यहाँ T मूल है और pre-order भी T से ही शुरू होगा — चारों विकल्प ऐसे ही हैं। T के बाद pre-order में पहले बाएँ उपवृक्ष के सारे node आते हैं, और post-order में भी वही node पहले बैठे होते हैं। तीसरे विकल्प में बायाँ उपवृक्ष O, P, Q और दायाँ R, S बनकर दोनों क्रम मेल खा जाते हैं; बाक़ी तीनों में यह बँटवारा कहीं नहीं बैठता।
In post-order the root comes last, so T is the root here and the pre-order must also begin with T; all four options do, so more checking is needed. After T, pre-order lists every node of the left subtree first, and post-order places those same nodes first. In the third option the left subtree is O, P, Q and the right one is R, S, and both orders then agree. No such split works for the other three.
प्रश्न 8उत्तर + हल
Branch and Bound क्या है?
Branch and Bound is a:
  1. Aसमस्या हल करने की तकनीक (problem solving technique)Problem solving technique
  2. Bडेटा संरचना (data structure)Data structure
  3. Cछँटाई विधि (sorting algorithm)Sorting algorithm
  4. Dवृक्ष का एक प्रकार (type of tree)Type of tree

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

हल / Solution
Branch and Bound एक समस्या हल करने की तकनीक (problem solving technique) है, कोई डेटा संरचना या छँटाई विधि नहीं। इसका उपयोग संयोजनात्मक अनुकूलन (combinatorial optimization) की समस्याओं में होता है, जैसे फेरीवाला समस्या और 0/1 knapsack। «Branch» का अर्थ है समस्या को उप-समस्याओं में बाँटना और «bound» का अर्थ है हर शाखा के लिए सीमा निकालना। जिस शाखा की सीमा अब तक के सर्वोत्तम हल से ख़राब हो, उसे छोड़ दिया जाता है।
Branch and bound is a problem solving technique, not a data structure or a sorting method. It is used for combinatorial optimization problems such as the travelling salesman problem, the assignment problem and 0/1 knapsack. Branching means splitting a problem into sub-problems, and bounding means computing a limit for each branch. A branch whose bound is worse than the best solution found so far is pruned, which saves work.
प्रश्न 9उत्तर + हल
निम्न में से कौन-सी branch and bound रणनीति नहीं होती?
Which of the following is NOT a branch and bound strategy?
  1. ALIFO branch and bound
  2. BFIFO branch and bound
  3. Cन्यूनतम लागत (lowest cost) branch and boundLowest cost branch and bound
  4. Dअधिकतम लागत (highest cost) branch and boundHighest cost branch and bound

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

हल / Solution
Branch and bound की मानक रणनीतियाँ तीन हैं — LIFO यानी ढेर के साथ गहराई-पहले, FIFO यानी क़तार के साथ चौड़ाई-पहले, और न्यूनतम लागत यानी प्राथमिकता क़तार के साथ सर्वोत्तम-पहले। «अधिकतम लागत» नाम की कोई रणनीति नहीं होती, क्योंकि इन समस्याओं में लक्ष्य लागत घटाना है; सबसे महँगी शाखा पहले खोलना उद्देश्य के ही उलट पड़ेगा और काम बढ़ा देगा। इसलिए जो रणनीति नहीं है, वह चौथा विकल्प है।
Branch and bound has three standard strategies: LIFO with a stack, which runs depth first; FIFO with a queue, which runs breadth first; and lowest cost with a priority queue, which runs best first. There is no strategy called highest cost, because the aim in these problems is to cut cost, and expanding the most expensive branch first would work against that aim. So the fourth option is the one that does not exist.
प्रश्न 10उत्तर + हल
LIFO branch and bound लागू करने के लिए कौन-सा data structure काम आता है?
Which data structure is used for implementing LIFO branch and bound?
  1. Aढेर (stack)Stack
  2. Bक़तार (queue)Queue
  3. Cऐरे (array)Array
  4. Dलिंक्ड लिस्ट (linked list)Linked list

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

हल / Solution
LIFO का अर्थ है बाद में आया, पहले गया — और यही ढेर (stack) का नियम है। इसलिए LIFO branch and bound में live node ढेर में रखे जाते हैं और सबसे ताज़ा जुड़ा node पहले खोला जाता है। इससे खोज एक शाखा में गहराई तक उतरती है, यानी गहराई-पहले खोज (depth first search) बनती है, और स्मृति भी कम लगती है। क़तार (queue) FIFO रूप में लगती है, और न्यूनतम लागत वाले रूप में प्राथमिकता क़तार।
LIFO means last in, first out, which is the rule of a stack. So LIFO branch and bound keeps the live nodes on a stack and expands the newest node first. The search then descends deep along one branch, giving depth first order, and it also needs little memory because only the current path is stored. A queue is used for the FIFO form, and a priority queue for the least cost form.
आगे के 20 प्रश्नों के उत्तर और हल app मेंFliQi Question Bank — अभ्यास, हल और आपकी प्रगति
App खोलिए
प्रश्न 12उत्तर app में
Best-first branch and bound के लिए सबसे उपयुक्त data structure कौन-सा है?
Which data structure is most suitable for best-first branch and bound?
  1. Aढेर (stack)Stack
  2. Bक़तार (queue)Queue
  3. Cप्राथमिकता क़तार (priority queue)Priority queue
  4. Dलिंक्ड लिस्ट (linked list)Linked list
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 13उत्तर app में
FIFO branch and bound किस खोज पर ले जाता है?
FIFO branch and bound strategy leads to which search?
  1. ALIFO branch and bound
  2. BFIFO branch and bound
  3. Cचौड़ाई-पहले खोज (breadth first search)Breadth first search
  4. Dगहराई-पहले खोज (depth first search)Depth first search
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 14उत्तर app में
LIFO branch and bound किस खोज पर ले जाता है?
LIFO branch and bound strategy leads to which search?
  1. Aचौड़ाई-पहले खोज (breadth first search)Breadth first search
  2. Bगहराई-पहले खोज (depth first search)Depth first search
  3. Cसर्वोत्तम-पहले खोज (best first search)Best first search
  4. Dरैखिक खोज (linear search)Linear search
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 15उत्तर app में
निम्न में से कौन state space tree को केवल DFS तरीक़े से traverse कर सकता है?
Which of the following can traverse the state space tree only in DFS manner?
  1. Aब्रांच एंड बाउंड (branch and bound)Branch and bound
  2. Bगतिशील प्रोग्रामिंग (dynamic programming)Dynamic programming
  3. Cलालची विधि (greedy algorithm)Greedy algorithm
  4. Dबैकट्रैकिंग (backtracking)Backtracking
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 16उत्तर app में
सही कथन चुनिए:
Choose the correct statement:
  1. ABranch and bound, backtracking से अधिक कुशल हैBranch and bound is more efficient than backtracking
  2. Bजहाँ लालची विधि लागू नहीं होती, वहाँ branch and bound उपयुक्त नहीं हैBranch and bound is not suitable where greedy is not applicable
  3. CBranch and bound किसी समस्या को कम से कम 2 नई प्रतिबंधित (restricted) उप-समस्याओं में बाँटता हैBranch and bound divides a problem into at least 2 new restricted sub-problems
  4. DBacktracking किसी समस्या को कम से कम 2 नई प्रतिबंधित (restricted) उप-समस्याओं में बाँटता हैBacktracking divides a problem into at least 2 new restricted sub-problems
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 17उत्तर app में
Fractional knapsack सबसे कुशलता से किस विधि से हल होता है?
Fractional knapsack is solved most efficiently by which algorithm?
  1. Aविभाजन और विजय (divide and conquer)Divide and conquer
  2. Bगतिशील प्रोग्रामिंग (dynamic programming)Dynamic programming
  3. Cलालची विधि (greedy algorithm)Greedy algorithm
  4. Dबैकट्रैकिंग (backtracking)Backtracking
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 18उत्तर app में
Knapsack समस्या का उद्देश्य क्या होता है?
What is the objective of the knapsack problem?
  1. Aबैग में कुल मूल्य (value) अधिकतम करनाMaximum total value in knapsack
  2. Bबैग में कुल मूल्य न्यूनतम करनाMinimum total value in knapsack
  3. Cबैग में वज़न अधिकतम करनाMaximum weight in knapsack
  4. Dबैग में वज़न न्यूनतम करनाMinimum weight in knapsack
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 20उत्तर app में
Fractional knapsack में सबसे अधिक समय लेने वाला चरण कौन-सा है?
The main time taking step in fractional knapsack is:
  1. Aitems को अंशों में तोड़नाBreaking items into fraction
  2. Bitems को बैग में डालनाAdding items into knapsack
  3. Cछँटाई (sorting)Sorting
  4. Dछँटी सूची पर loop चलानाLooping through sorted items
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 22उत्तर app में
Linear search में worst case कब आता है?
The worst case occurs in linear search when:
  1. Aआइटम कहीं बीच में होItem somewhere in middle
  2. Bआइटम array में हो ही नहींItem not in array
  3. Cआइटम आख़िरी element होItem is last element
  4. Dआइटम आख़िरी element हो या बिलकुल मौजूद ही न होItem is last element or not present at all
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 23उत्तर app में
Quick sort में worst case कब आता है?
The worst case occurs in quick sort when:
  1. APivot, array का median होPivot is median of array
  2. BPivot सबसे छोटा element होPivot is smallest element
  3. CPivot बीच वाला element होPivot is middle element
  4. Dइनमें से कोई नहींNone of the mentioned
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 24उत्तर app में
Time complexity मापने के लिए Big-O notation का उपयोग होता है, क्योंकि यह:
To measure time complexity, Big O notation is used because it:
  1. Aसीमांत बरताव (limiting behaviour) बताता हैDescribes limiting behaviour
  2. Bवृद्धि के आधार पर function को वर्गीकृत करता हैCharacterises function based on growth
  3. Cवृद्धि-दर की ऊपरी सीमा देता हैUpper bound on growth rate
  4. Dऊपर कहे गए सभीAll of the mentioned
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
Introduction to Data Structures & Algorithms के सभी 436 प्रश्न — उत्तर, हल और अभ्यास

FliQi Question Bank app में topic-वार अभ्यास, कठिनाई-स्तर और आपकी प्रगति।

  • पहला test मुफ़्त
  • हिंदी + English
  • जाँचे हुए उत्तर और हल

यह topic किन परीक्षाओं में आता है

DSA के दूसरे topics

सभी topics