पहले 10 प्रश्नों के उत्तर और हल यहीं खुले हैं; बाक़ी 20 के उत्तर और हल FliQi Question Bank app में।
भाषा
प्रश्न 1उत्तर + हल
Pre-order traversal का सही क्रम क्या है?
What is the correct order of pre-order traversal?
ALeft, Root, Right
BRoot, Left, Right
CLeft, Right, Root
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?
Aसबसे बाएँ वाला पत्ता (leftmost leaf)Leftmost leaf
Bमूल (root)Root
Cसबसे दाएँ वाला पत्ता (rightmost leaf)Rightmost leaf
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?
Aगहराई-पहले खोज (depth first search)Depth First Search
Bचौड़ाई-पहले खोज (breadth first search)Breadth First Search
Cद्विआधारी खोज (binary search)Binary Search
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?
Aगहराई-पहले खोज (depth first search)Depth First Search
Bचौड़ाई-पहले खोज (breadth first search)Breadth First Search
Cगहराई और चौड़ाई-पहले खोज, दोनोंDepth & Breadth First Search
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?
A15
B3
C5
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?
APost-order और pre-orderPost-order and pre-order
BPost-order और in-orderPost-order and in-order
CPost-order और level-orderPost-order and level-order
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?
AT Q R S O P
BT O Q R P S
CT Q O P S R
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:
Aसमस्या हल करने की तकनीक (problem solving technique)Problem solving technique
Bडेटा संरचना (data structure)Data structure
Cछँटाई विधि (sorting algorithm)Sorting algorithm
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?
ALIFO branch and bound
BFIFO branch and bound
Cन्यूनतम लागत (lowest cost) branch and boundLowest cost branch and bound
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?
Aढेर (stack)Stack
Bक़तार (queue)Queue
Cऐरे (array)Array
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 — अभ्यास, हल और आपकी प्रगति
ABranch and bound, backtracking से अधिक कुशल हैBranch and bound is more efficient than backtracking
Bजहाँ लालची विधि लागू नहीं होती, वहाँ branch and bound उपयुक्त नहीं हैBranch and bound is not suitable where greedy is not applicable
CBranch and bound किसी समस्या को कम से कम 2 नई प्रतिबंधित (restricted) उप-समस्याओं में बाँटता हैBranch and bound divides a problem into at least 2 new restricted sub-problems
DBacktracking किसी समस्या को कम से कम 2 नई प्रतिबंधित (restricted) उप-समस्याओं में बाँटता हैBacktracking divides a problem into at least 2 new restricted sub-problems