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

Tree — प्रश्न और उत्तर

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

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

पहले 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
  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.
प्रश्न 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
  1. Ai - 1
  2. B⌊i/2⌋
  3. C2i
  4. 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?
  1. Aसर्कुलर लिस्टcircular list
  2. Bसिंगली लिंक्ड लिस्टsingly linked list
  3. Cडबली लिंक्ड लिस्टdoubly linked list
  4. 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?
  1. An-1
  2. B(n-1)/2
  3. Cn/2
  4. 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
  1. Aबाइनरी सर्च ट्रीbinary search tree
  2. Bएवीएल ट्रीAVL tree
  3. Cकम्पलीट बैलेंस्ड ट्रीcompletely balanced tree
  4. 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?
  1. Aबाइनरी सर्च ट्रीBinary search tree
  2. Bएवीएल ट्रीAVL tree
  3. Cकम्पलीट ट्रीComplete tree
  4. 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?
  1. Aप्रीऑर्डर ट्रैवर्सलPreorder traversal
  2. Bपोस्टऑर्डर ट्रैवर्सलPostorder traversal
  3. Cइनऑर्डर ट्रैवर्सलInorder traversal
  4. 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?
  1. Aइनऑर्डरInorder
  2. Bप्रीऑर्डरPreorder
  3. Cपोस्टऑर्डरPostorder
  4. 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
  1. Aप्रीऑर्डरpreorder
  2. Bइनऑर्डरinorder
  3. Cपोस्टऑर्डरpostorder
  4. 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
  1. Aकम्पलीट ट्रीcomplete tree
  2. Bफुल बाइनरी ट्रीfull binary tree
  3. Cबाइनरी सर्च ट्रीbinary search tree
  4. 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 — अभ्यास, हल और आपकी प्रगति
App खोलिए
प्रश्न 11उत्तर app में
वह बाइनरी ट्री जिसमें अंतिम स्तर को छोड़कर सभी स्तरों पर नोड्स की अधिकतम संख्या हो और अंतिम स्तर के सभी नोड यथासंभव बाईं ओर हों, कहलाता है
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
  1. Aफुल बाइनरी ट्रीfull binary tree
  2. B2-ट्री2-tree
  3. Cट्रीtrees
  4. Dकम्पलीट बाइनरी ट्रीcomplete binary tree
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 14उत्तर app में
किसी बाइनरी ट्री की ऊँचाई (गहराई) h है, जहाँ h स्तरों की संख्या है। उसमें नोड्स की अधिकतम संख्या होगी
The maximum number of nodes in a binary tree of height (depth) h, where h is the number of levels, is
  1. A2h+1 - 1
  2. B3h-2
  3. C2h - 1
  4. D2h + 1
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 17उत्तर app में
वह ट्री जिसमें एक मुख्य नोड होता है और जिसका कोई पूर्ववर्ती नहीं होता, कहलाता है
A tree having a main node, which has no predecessor, is a
  1. Aस्पैनिंग ट्रीspanning tree
  2. Bरूटेड ट्रीrooted tree
  3. Cवेटेड ट्रीweighted tree
  4. Dये सभीAll of these
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 19उत्तर app में
वह ट्री जिसमें किसी नोड की डिग्री अधिकतम दो हो, कहलाता है
The tree, in which the degree of any node is at most two, is called
  1. Aबाइनरी ट्रीbinary tree
  2. Bहाइट बैलेंस्ड ट्रीheight balanced tree
  3. Cबी-ट्रीB-tree
  4. Dये सभीAll of these
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 20उत्तर app में
जड़ से टर्मिनल नोड तक उतरने पर मिलने वाले स्तरों की संख्या को कहते हैं
The number of levels one can descend the tree from its root to the terminal nodes is known as
  1. Aगहराईdepth
  2. Bऊँचाईheight
  3. Cदूरीdistance
  4. D(a) और (b) दोनोंBoth (a) and (b)
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 23उत्तर app में
निम्नलिखित में से कौन-सा ट्री का लक्षण नहीं है?
Which of the following is not a feature of a tree?
  1. Aयह एक डेटा स्ट्रक्चर हैIt is a data structure
  2. Bइसका एक मुख्य नोड होता है जिसे रूट कहते हैंIt has a main node called root
  3. Cइसमें एक नोड से दूसरे नोड तक केवल एक ही रास्ता होता हैIt has only one path from a node to another node
  4. Dइसमें साइकल हो सकती हैIt can have a cycle
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 26उत्तर app में
स्प्ले ट्री (splay trees) क्या हैं?
What are splay trees?
  1. Aस्वयं समायोजित बाइनरी सर्च ट्रीself adjusting binary search trees
  2. Bस्वयं समायोजित बाइनरी ट्रीself adjusting binary trees
  3. Cस्ट्रिंग वाला ट्रीa tree with strings
  4. Dप्रायिकता बंटन वाला ट्रीa tree with probability distributions
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 27उत्तर app में
रेड-ब्लैक ट्री का विशेष गुण क्या है और उसकी जड़ (root) हमेशा कैसी होनी चाहिए?
What is the special property of red-black trees and what should the root always be?
  1. Aहर नोड का रंग या तो लाल या काला होता है और जड़ हमेशा केवल काले रंग की होनी चाहिएa colour which is either red or black and the root should always be black only
  2. Bट्री की ऊँचाईheight of the tree
  3. Cअगले नोड का पॉइंटरpointer to next node
  4. Dऐसा रंग जो या तो हरा हो या कालाa colour which is either green or black
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 28उत्तर app में
एवीएल ट्री (AVL tree) क्या है?
What is an AVL tree?
  1. Aऐसा ट्री जो संतुलित है और ऊँचाई से संतुलित (height balanced) ट्री हैa tree which is balanced and is a height balanced tree
  2. Bऐसा ट्री जो असंतुलित है और ऊँचाई से संतुलित ट्री हैa tree which is unbalanced and is a height balanced tree
  3. Cतीन बच्चों वाला ट्रीa tree with three children
  4. Dअधिकतम तीन बच्चों वाला ट्रीa tree with atmost 3 children
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 29उत्तर app में
एवीएल ट्री एक सेल्फ़ बैलेंसिंग बाइनरी सर्च ट्री है, जिसमें किसी भी नोड के दोनों चाइल्ड उप-वृक्षों की ऊँचाई में कितना अंतर हो सकता है?
An AVL tree is a self-balancing binary search tree, in which the heights of the two child subtrees of any node differ by _________
  1. Aकम से कम एक (At least one)At least one
  2. Bअधिकतम एक (At most one)At most one
  3. Cदो (Two)Two
  4. Dअधिकतम दो (At most two)At most two
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 30उत्तर app में
निम्नलिखित में से कौन सेल्फ़ बैलेंसिंग बाइनरी सर्च ट्री नहीं है?
Which of the following is not a self balancing binary search tree?
  1. Aएवीएल ट्री (AVL Tree)AVL Tree
  2. B2-3-4 ट्री (2-3-4 Tree)2-3-4 Tree
  3. Cरेड-ब्लैक ट्री (Red-Black Tree)Red-Black Tree
  4. Dस्प्ले ट्री (Splay Tree)Splay Tree
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
Tree के सभी 56 प्रश्न — उत्तर, हल और अभ्यास

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

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

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

DSA के दूसरे topics

सभी topics