पहले 10 प्रश्नों के उत्तर और हल यहीं खुले हैं; बाक़ी 20 के उत्तर और हल FliQi Question Bank app में।
भाषा
प्रश्न 1उत्तर + हल
फुल बाइनरी ट्री में यदि आंतरिक नोड की संख्या I हो, तो लीफ़ L कितनी होंगी?
In a full binary tree, if the number of internal nodes is I, then the number of leaves L is
AL = 2I
BL = I + 1
CL = I - 1
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.
प्रश्न 2उत्तर + हल
बाइनरी हीप के सरणी रूप (index 1 से n) में index i वाले element का parent कौन होता है?
In an array representation of a binary heap (index 1 to n), the parent of the element at index i is
Ai - 1
B⌊i/2⌋
C2i
D(i+1)/2
सही उत्तर / Answer: (B)
हल / Solution
हीप एक कम्पलीट बाइनरी ट्री होता है, इसलिए उसे स्तर दर स्तर सरणी में भरा जा सकता है। 1 से शुरू होने वाली सरणी में index i के बच्चे 2i और 2i + 1 पर बैठते हैं। इसे उलटने पर पैरेंट का सूत्र मिलता है — i को 2 से भाग देकर नीचे का पूर्णांक, यानी ⌊i/2⌋। जाँचिए — i = 5 का पैरेंट 2 है और 2 के बच्चे 4 तथा 5 हैं। विकल्प 2i बायाँ बच्चा है।
A heap is a complete binary tree, so it can be packed into an array level by level. With indexing that starts at 1, the children of index i sit at 2i and 2i + 1. Turning that around gives the parent formula: divide i by 2 and take the floor, that is ⌊i/2⌋. Check it with i = 5, whose parent is 2, and the children of 2 are 4 and 5. The option 2i is the left child.
प्रश्न 3उत्तर + हल
ट्री के लिए, निम्नलिखित में से किस लिस्ट में पूरी लिस्ट से गुज़रना आवश्यक नहीं है?
For a tree, in which of the following lists is traversing through the entire list not necessary?
Aसर्कुलर लिस्टcircular list
Bसिंगली लिंक्ड लिस्टsingly linked list
Cडबली लिंक्ड लिस्टdoubly linked list
D(b) और (c) दोनोंBoth (b) and (c)
सही उत्तर / Answer: (A)
हल / Solution
सर्कुलर लिस्ट में अंतिम नोड फिर से पहले नोड की ओर इशारा करता है, इसलिए शृंखला कहीं टूटती नहीं। इसका फ़ायदा यह है कि किसी भी नोड से चलना शुरू कीजिए, घूमकर हर नोड तक पहुँचा जा सकता है। यानी हर बार शुरुआत से पूरी लिस्ट पार करने की ज़रूरत नहीं पड़ती। सिंगली लिंक्ड लिस्ट में चलना हमेशा सिर से शुरू करना पड़ता है। डबली लिंक्ड लिस्ट दोनों दिशाएँ देती है, पर सिरा वहाँ भी बंद ही रहता है।
In a circular list the last node points back to the first one, so the chain never ends. The gain is that you may start from any node and still reach every other node by going round. You therefore do not have to walk the whole list from the head each time. In a singly linked list movement always has to begin at the head. A doubly linked list allows both directions, but its ends are still closed.
प्रश्न 4उत्तर + हल
वह बैलेंस्ड ऑर्डर-n मल्टीवे सर्च ट्री जिसमें प्रत्येक गैर-रूट नोड में कम से कम .......... कुंजियाँ होती हैं, ऑर्डर n का बी-ट्री कहलाता है?
A balanced order-n multiway search tree in which each non-root node contains at least .......... keys is called a B-tree of order n?
An-1
B(n-1)/2
Cn/2
D(n-1) 2
सही उत्तर / Answer: (B)
हल / Solution
ऑर्डर n के बी-ट्री में किसी नोड में ज़्यादा से ज़्यादा n - 1 कुंजियाँ रखी जा सकती हैं। नोड आधे से कम ख़ाली न रहे, यही संतुलन की शर्त है। इसलिए रूट को छोड़कर हर नोड में कम से कम (n - 1)/2 कुंजियाँ होनी चाहिए। रूट पर यह छूट रहती है, वहाँ एक कुंजी से भी काम चल जाता है। विकल्प n - 1 अधिकतम सीमा है, न्यूनतम नहीं।
In a B-tree of order n a node can hold at most n - 1 keys. The balance rule says a node must never fall below half full. So every node other than the root must carry at least (n - 1)/2 keys. The root is exempt from this rule and may hold as little as one key. The option n - 1 is the upper limit rather than the lower one, and n/2 counts children rather than keys.
प्रश्न 5उत्तर + हल
वह बाइनरी ट्री जिसमें प्रत्येक नोड का मान उसके बच्चों के मानों से कम से कम उतना बड़ा हो, कहलाता है
A binary tree with the property that the value at each node is at least as large as the values at its children is known as
Aबाइनरी सर्च ट्रीbinary search tree
Bएवीएल ट्रीAVL tree
Cकम्पलीट बैलेंस्ड ट्रीcompletely balanced tree
Dहीप ट्रीheap tree
सही उत्तर / Answer: (D)
हल / Solution
जिस ट्री में हर पैरेंट अपने बच्चों से छोटा न हो, वह मैक्स हीप कहलाता है। प्रश्न में यही शर्त दी गई है, इसलिए उत्तर हीप ट्री है। इसी गुण के कारण सबसे बड़ा मान हमेशा जड़ पर मिलता है और प्राथमिकता कतार बनाना आसान हो जाता है। बाइनरी सर्च ट्री में शर्त बाएँ-दाएँ की होती है, ऊपर-नीचे की नहीं। एवीएल ट्री ऊँचाई संतुलित रखता है और कम्पलीट बैलेंस्ड ट्री सिर्फ़ ढाँचे की बात करता है।
A tree in which every parent is at least as large as its children is called a max heap, which is exactly the property stated in the stem. Because of it the largest value always sits at the root, which makes a priority queue easy to build. A binary search tree orders values left and right, not top and bottom. An AVL tree only keeps the height balanced, and a completely balanced tree is a statement about shape alone.
प्रश्न 6उत्तर + हल
किस ट्री में प्रत्येक नोड के बाएँ और दाएँ उपवृक्ष की ऊँचाई में अधिकतम एक का अंतर होता है?
In which tree, for every node, do the heights of its left subtree and right subtree differ by at most one?
Aबाइनरी सर्च ट्रीBinary search tree
Bएवीएल ट्रीAVL tree
Cकम्पलीट ट्रीComplete tree
Dथ्रेडेड बाइनरी ट्रीThreaded binary tree
सही उत्तर / Answer: (B)
हल / Solution
एवीएल ट्री दरअसल ऊँचाई से संतुलित बाइनरी सर्च ट्री है। उसकी शर्त यही है कि हर नोड पर बाएँ और दाएँ उपवृक्ष की ऊँचाई का अंतर 1 से ज़्यादा न हो। इस अंतर को बैलेंस फ़ैक्टर कहते हैं और वह केवल -1, 0 या +1 रह सकता है। शर्त टूटते ही घुमाव लगाकर ट्री फिर संतुलित कर दिया जाता है। साधारण बाइनरी सर्च ट्री पर ऐसी कोई शर्त नहीं होती, इसलिए वह एक सीधी शृंखला तक बन सकता है।
An AVL tree is really a height balanced binary search tree. Its rule is that at every node the heights of the left and right subtrees may differ by at most one. This difference is called the balance factor, and it can only be -1, 0 or +1. As soon as the rule breaks, a rotation is applied and the tree is balanced again. An ordinary binary search tree has no such rule, so it can degenerate into a chain.
प्रश्न 7उत्तर + हल
किस ट्रैवर्सिंग में हम रूट को सबसे अंत में ट्रैवर्स करते हैं?
In which traversing do we traverse the root at last?
Aप्रीऑर्डर ट्रैवर्सलPreorder traversal
Bपोस्टऑर्डर ट्रैवर्सलPostorder traversal
Cइनऑर्डर ट्रैवर्सलInorder traversal
Dये सभीAll of these
सही उत्तर / Answer: (B)
हल / Solution
पोस्टऑर्डर का क्रम है बायाँ, फिर दायाँ, और सबसे अंत में जड़। यानी दोनों उपवृक्ष पूरे पढ़े जाने के बाद ही जड़ की बारी आती है। इसी वजह से ट्री को मिटाने या पोस्टफ़िक्स रूप निकालने में पोस्टऑर्डर काम आता है, क्योंकि बच्चे पहले निपट जाते हैं। प्रीऑर्डर में जड़ सबसे पहले पढ़ी जाती है और इनऑर्डर में दोनों उपवृक्षों के बीच। इसलिए ये सभी वाला विकल्प ग़लत हो जाता है।
Postorder visits the left subtree, then the right subtree, and the root only at the very end. The root's turn comes only after both subtrees are finished. This is why postorder is used to delete a tree or to build its postfix form, since the children are dealt with first. Preorder reads the root before anything else, and inorder reads it between the two subtrees. That makes the option all of these wrong.
प्रश्न 8उत्तर + हल
बाइनरी सर्च ट्री को किस तरह ट्रैवर्स करने पर मान आरोही क्रम में मिलते हैं?
If we traverse a binary search tree, in which manner do we get the values in ascending order?
Aइनऑर्डरInorder
Bप्रीऑर्डरPreorder
Cपोस्टऑर्डरPostorder
Dग्राफ़Graph
सही उत्तर / Answer: (A)
हल / Solution
बाइनरी सर्च ट्री में हर नोड का बायाँ उपवृक्ष उससे छोटा और दायाँ उपवृक्ष उससे बड़ा होता है। इनऑर्डर का क्रम है बायाँ, फिर जड़, फिर दायाँ — यानी पहले सारे छोटे, फिर नोड, फिर सारे बड़े। इसी वजह से इनऑर्डर पढ़ने पर मान अपने आप आरोही क्रम में निकलते हैं। प्रीऑर्डर और पोस्टऑर्डर में जड़ पहले या अंत में आती है, इसलिए क्रम बिगड़ जाता है। ग्राफ़ कोई ट्रैवर्सल विधि है ही नहीं।
In a binary search tree the left subtree of a node holds smaller values and the right subtree holds larger ones. Inorder visits the left subtree, then the node, then the right subtree, so it gives all the smaller values, then the node, then the larger ones. That is why an inorder walk returns the values already sorted in ascending order. Preorder and postorder place the root first or last, which breaks the order. Graph is not a traversal method.
प्रश्न 9उत्तर + हल
ट्री का ऊपर से नीचे की ओर ट्रैवर्सिंग कहलाता है
Top to down traversing of a tree is
Aप्रीऑर्डरpreorder
Bइनऑर्डरinorder
Cपोस्टऑर्डरpostorder
Dये सभीAll of these
सही उत्तर / Answer: (A)
हल / Solution
ऊपर से नीचे की ओर चलने का मतलब है कि पहले जड़ पढ़ी जाए और फिर नीचे के नोड। प्रीऑर्डर में यही होता है — जड़, फिर बायाँ उपवृक्ष, फिर दायाँ उपवृक्ष। इसीलिए ट्री की नक़ल बनाने या प्रीफ़िक्स रूप निकालने में प्रीऑर्डर काम आता है। इनऑर्डर में जड़ बीच में आती है और पोस्टऑर्डर में सबसे अंत में, यानी वहाँ चाल नीचे से ऊपर की होती है। इसलिए ये सभी वाला विकल्प ग़लत है।
Going from the top downward means the root is read first and the lower nodes after it. Preorder does exactly that: root, then the left subtree, then the right subtree. This is why preorder is used to copy a tree or to produce its prefix form. In inorder the root comes in the middle, and in postorder it comes last, so those two work their way upward instead. Hence the option all of these is wrong.
प्रश्न 10उत्तर + हल
यदि किसी ट्री में प्रत्येक नोड का मान उसके बाएँ उपवृक्ष के हर मान से बड़ा और दाएँ उपवृक्ष के हर मान से छोटा हो, तो वह ट्री कहलाता है
If each node in a tree has a value greater than every value of its left subtree and less than every value of its right subtree, the tree is known as
Aकम्पलीट ट्रीcomplete tree
Bफुल बाइनरी ट्रीfull binary tree
Cबाइनरी सर्च ट्रीbinary search tree
Dथ्रेडेड ट्रीthreaded tree
सही उत्तर / Answer: (C)
हल / Solution
प्रश्न में जो शर्त लिखी है वही बाइनरी सर्च ट्री की मूल शर्त है — बायाँ उपवृक्ष छोटा, जड़ बीच में, दायाँ उपवृक्ष बड़ा। इसी क्रम की वजह से खोज हर क़दम पर आधा हिस्सा छोड़ देती है। कम्पलीट ट्री और फुल बाइनरी ट्री दोनों ढाँचे से जुड़ी परिभाषाएँ हैं, उनमें मानों के क्रम की कोई शर्त नहीं होती। थ्रेडेड ट्री में ख़ाली पॉइंटर को ट्रैवर्सल तेज़ करने के लिए काम में लिया जाता है।
The condition stated in the stem is the defining rule of a binary search tree: everything in the left subtree is smaller, the root sits in between, and everything in the right subtree is larger. That ordering is what lets a search throw away half the tree at each step. A complete tree and a full binary tree are defined by shape alone and say nothing about the values. A threaded tree reuses empty pointers to speed up traversal.
आगे के 20 प्रश्नों के उत्तर और हल app मेंFliQi Question Bank — अभ्यास, हल और आपकी प्रगति
वह बाइनरी ट्री जिसमें अंतिम स्तर को छोड़कर सभी स्तरों पर नोड्स की अधिकतम संख्या हो और अंतिम स्तर के सभी नोड यथासंभव बाईं ओर हों, कहलाता है
A binary tree in which all its levels except possibly the last have the maximum number of nodes, and all the nodes at the last level appear as far left as possible, is known as
रेड-ब्लैक ट्री का विशेष गुण क्या है और उसकी जड़ (root) हमेशा कैसी होनी चाहिए?
What is the special property of red-black trees and what should the root always be?
Aहर नोड का रंग या तो लाल या काला होता है और जड़ हमेशा केवल काले रंग की होनी चाहिएa colour which is either red or black and the root should always be black only
Bट्री की ऊँचाईheight of the tree
Cअगले नोड का पॉइंटरpointer to next node
Dऐसा रंग जो या तो हरा हो या कालाa colour which is either green or black