FliQi Education App Download
Senior Computer Instructor — Paper II · प्रश्न-बैंक

Senior Computer Instructor — Paper II — DSA के प्रश्न

654 जाँचे हुए प्रश्न · 9 topics · परीक्षा में 12 प्रश्न

Topics

प्रश्न

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

भाषा
प्रश्न 1उत्तर + हल Tree
निम्नलिखित में से कौन-सी आकृति संतुलित बाइनरी ट्री है?
Which of the following figures is a balanced binary tree?
  1. Aप्रश्न का चित्र
  2. Bप्रश्न का चित्र
  3. Cप्रश्न का चित्र
  4. Dप्रश्न का चित्र

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

हल / Solution
संतुलित बाइनरी ट्री में हर नोड पर बाएँ और दाएँ उप-वृक्ष की ऊँचाई का अंतर अधिकतम एक होना चाहिए। दूसरी आकृति में जड़ के बाएँ दो पत्तियाँ हैं और दाएँ एक, और किसी नोड पर अंतर एक से ज़्यादा नहीं जाता, इसलिए वही संतुलित है। पहली आकृति में एक ओर की शाखा तीन स्तर लंबी है, दूसरी ओर केवल एक नोड। तीसरी और चौथी में एक नोड के नीचे दो स्तर हैं और दूसरी ओर कुछ नहीं।
In a balanced binary tree the heights of the left and right subtrees must differ by at most one at every node. In the second figure the root has two leaves on its left and one on its right, and no node breaks that limit, so it is balanced. In the first, one branch runs three levels deep while the other side holds one node. The third and fourth have two levels below a node on one side only.
प्रश्न 2उत्तर + हल Introduction to Data Structures & Algorithms
Graph traversal, tree traversal से अलग क्यों होता है?
Graph traversal is different from tree traversal because:
  1. ATree जुड़ा हुआ नहीं होताTree is not connected
  2. BGraph में loops हो सकते हैंGraph may have loops
  3. CTree में जड़ होती हैTree has root
  4. DTree traversal में visited array रखना पड़ता हैTree traversal needs a visited array

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

हल / Solution
पेड़ (tree) एक चक्र-रहित जुड़ा हुआ graph है जिसमें हर node तक ठीक एक ही रास्ता जाता है, इसलिए उसे घूमते हुए कोई node दोबारा नहीं आता। पर सामान्य graph में loop और चक्र हो सकते हैं। इसी कारण graph में BFS या DFS चलाते समय देखे गए node का हिसाब (visited array) रखना पड़ता है, वरना algorithm चक्र में फँसकर अनंत चलता रहता है। यही अतिरिक्त हिसाब असली फ़र्क़ है।
A tree is a connected acyclic graph in which exactly one path reaches each node, so a traversal never meets the same node twice. A general graph, however, may contain loops and cycles, and several paths may lead to one node. That is why BFS or DFS on a graph must keep a record of visited nodes, otherwise the algorithm falls into a cycle and runs forever. This extra bookkeeping is the real difference.
प्रश्न 3उत्तर + हल Stack
इनफ़िक्स नोटेशन को पोस्टफ़िक्स नोटेशन में बदलने के लिए किस डेटा संरचना की ज़रूरत होती है?
Which data structure is needed to convert infix notation to postfix notation?
  1. ABranch / ब्रांचBranch
  2. BTree / ट्रीTree
  3. CQueue / क्यूQueue
  4. DStack / स्टैकStack

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

हल / Solution
इनफ़िक्स से पोस्टफ़िक्स बनाते समय ऑपरेंड सीधे आउटपुट में चले जाते हैं, पर चिह्नों को रोककर रखना पड़ता है। किस चिह्न को कब निकालना है, यह उसकी प्राथमिकता और कोष्ठक तय करते हैं। जो चिह्न बाद में आया और ऊँची प्राथमिकता का है, वह पहले बाहर जाता है — यह उल्टा क्रम सिर्फ़ स्टैक दे सकता है। इसी तरीक़े को Shunting Yard कहते हैं। क्यू FIFO है, इसलिए वह यह क्रम नहीं देगा। ट्री और ब्रांच यहाँ साधन नहीं हैं।
While converting infix to postfix, operands go straight to the output but operators must be held back. Precedence and brackets decide when each held operator is released. An operator that arrived later with higher precedence leaves first, and only a stack can produce that reverse order. The method is known as the Shunting Yard algorithm. A queue is FIFO, so it cannot give that order. A tree or a branch is not the tool for this step.
प्रश्न 4उत्तर + हल Tree
निम्नलिखित में से कौन-सी ट्री डेटा संरचना संतुलित बाइनरी ट्री नहीं है?
Which of the following tree data structures is not a balanced binary tree?
  1. Aएवीएल ट्री (AVL tree)AVL tree
  2. Bरेड-ब्लैक ट्री (Red-black tree)Red-black tree
  3. Cस्प्ले ट्री (Splay tree)Splay tree
  4. Dबी-ट्री (B-tree)B-tree

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

हल / Solution
बाइनरी ट्री की शर्त है कि किसी भी नोड के अधिकतम दो बच्चे हों। बी-ट्री इस शर्त को ही तोड़ देता है, क्योंकि उसके एक नोड में कई कुंजियाँ और दो से कहीं ज़्यादा बच्चे हो सकते हैं। वह संतुलित तो रहता है, पर बाइनरी नहीं। एवीएल, रेड-ब्लैक और स्प्ले — तीनों बाइनरी सर्च ट्री हैं और तीनों ख़ुद को संतुलित रखने के नियम लगाते हैं, इसलिए वे प्रश्न की माँग पर खरे नहीं उतरते।
A binary tree must have at most two children at every node. A B-tree breaks that very condition, because a single node can hold several keys and far more than two children. It does stay balanced, but it is not binary. AVL, red-black and splay trees are all binary search trees and each of them applies rules to keep itself balanced, so none of them answers what the question is asking for.
प्रश्न 5उत्तर + हल Introduction to Data Structures & Algorithms
Full binary tree क्या होती है?
What is a full binary tree?
  1. Aहर node के ठीक शून्य या दो बच्चे होंEach node has exactly zero or two children
  2. Bहर node के ठीक दो बच्चे होंEach node has exactly two children
  3. Cसभी leaves एक ही स्तर पर होंAll leaves at same level
  4. Dहर node के ठीक एक या दो बच्चे होंEach node has exactly one or two children

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

हल / Solution
पूर्ण (full) binary tree — जिसे strict या proper भी कहते हैं — वह है जिसमें हर node के या शून्य बच्चे हों (यानी वह पत्ती है) या ठीक दो; एक बच्चे वाला node कहीं नहीं होता। इसी से सुंदर संबंध बनते हैं: भीतरी node I हों तो पत्तियाँ L=I+1 और कुल node N=2L−1। «हर node के ठीक दो बच्चे» ग़लत है, क्योंकि पत्तियों के बच्चे शून्य होते हैं। «सब पत्तियाँ एक स्तर पर» perfect पेड़ की बात है।
A full binary tree, also called strict or proper, is one in which every node has either zero children, that is it is a leaf, or exactly two; no node ever has a single child. This gives neat relations: with I internal nodes there are L=I+1 leaves and N=2L−1 nodes in all. Saying every node has exactly two children is wrong, because leaves have none, and leaves on one level describes a perfect tree.
प्रश्न 6उत्तर + हल Stack
सीरियल एक्सेस मेमोरी में रखे डेटा तक पहुँचने की प्रक्रिया ________ पर डेटा के साथ काम करने जैसी है
The process of accessing data stored in a serial access memory is similar to manipulating data on a ________
  1. AHeap Tree / हीप ट्रीHeap Tree
  2. BBinary Tree / बाइनरी ट्रीBinary Tree
  3. CGraph / ग्राफ़Graph
  4. DStack / स्टैकStack

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

हल / Solution
सीरियल एक्सेस मेमोरी में किसी जगह तक सीधे नहीं पहुँचा जा सकता। वहाँ डेटा एक तय क्रम में ही मिलता है, जैसे टेप में। स्टैक भी ऐसा ही है — अंदर पड़ा कोई तत्व सीधे नहीं पढ़ा जा सकता, ऊपर वाले पहले हटाने पड़ते हैं। इसी सीमित पहुँच की वजह से दोनों की तुलना की जाती है। हीप ट्री और बाइनरी ट्री में रास्ता चुनकर तेज़ी से पहुँचा जा सकता है। ग्राफ़ में तो कई रास्ते होते हैं।
Serial access memory does not let you jump straight to a location. Data comes in a fixed order, the way it does on a tape. A stack behaves the same way, because an element lying inside cannot be read directly and the ones above it must be removed first. That shared restriction is why the two are compared. A heap tree or a binary tree allows a guided path to any node, and a graph offers many paths.
प्रश्न 7उत्तर + हल Tree
आठ पत्तियों (leaves) वाले संतुलित पूर्ण बाइनरी ट्री की ऊँचाई कितनी होगी?
What will be the height of a balanced full binary tree with 8 leaves?
  1. A8
  2. B5
  3. C6
  4. D4

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

हल / Solution
पूर्ण बाइनरी ट्री में हर स्तर पर नोड दुगुने होते जाते हैं — 1, 2, 4, 8। आठ पत्तियाँ पाने के लिए जड़ के बाद तीन बार दुगुना करना पड़ा, यानी जड़ वाले स्तर को मिलाकर कुल चार स्तर बने। स्तरों की गिनती से ऊँचाई चार आती है, इसलिए विकल्प (D) सही है। आठ, पाँच और छह किसी गणना से नहीं निकलते; आठ तो पत्तियों की संख्या है, ऊँचाई नहीं।
In a full binary tree the number of nodes doubles at every level, giving 1, 2, 4, 8. To reach eight leaves the tree has to double three times after the root, so counting the root level as well there are four levels in all. Measuring height by levels gives four, so option (D) is correct. The values eight, five and six come from no calculation at all; eight is simply the number of leaves, not the height.
प्रश्न 8उत्तर + हल Introduction to Data Structures & Algorithms
Complete binary tree क्या होती है?
What is a complete binary tree?
  1. Aहर node के ठीक शून्य या दो बच्चे होंEach node has exactly zero or two children
  2. Bसबसे निचले स्तर को छोड़ पूरी भरी हो, निचला स्तर दाएँ से बाएँ भरा होFilled completely except bottom level, filled right to left
  3. Cसबसे निचले स्तर को छोड़ पूरी भरी हो, निचला स्तर बाएँ से दाएँ भरा होFilled completely except bottom level, filled left to right
  4. Dसभी leaves एक ही स्तर पर होंAll leaves lie at the same level

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

हल / Solution
पूर्ण-प्राय (complete) binary tree वह है जिसमें सबसे निचले स्तर को छोड़कर बाक़ी सब स्तर पूरे भरे रहते हैं, और निचले स्तर के node बाएँ से दाएँ, बीच में जगह ख़ाली छोड़े बिना बैठते हैं। इसी नियमित बनावट से ऐसा पेड़ array में कसकर रखा जा सकता है — index i के node का बायाँ बच्चा 2i पर, दायाँ 2i+1 पर; इसीलिए heap सदा complete होता है। «शून्य या दो बच्चे» full की परिभाषा है,।
A complete binary tree is one in which every level except the bottom one is entirely full, and the nodes of the bottom level sit from left to right with no gap between them. This regular shape lets the tree be packed tightly into an array: the node at index i has its left child at 2i and its right child at 2i+1, which is why a heap is always complete. Zero or two children defines a full tree.
प्रश्न 9उत्तर + हल Stack
किसी रिकर्सिव एल्गोरिदम के ग़ैर-रिकर्सिव रूप में आपको अक्सर कौन-सी डेटा संरचना दिखेगी?
What data structure would you most likely see in a non-recursive implementation of a recursive algorithm?
  1. ALinked List / लिंक्ड लिस्टLinked List
  2. BStack / स्टैकStack
  3. CQueue / क्यूQueue
  4. DTree / ट्रीTree

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

हल / Solution
रिकर्सन चलते समय हर कॉल के चर और लौटने का पता सिस्टम के call stack में जमा होते हैं। जब वही एल्गोरिदम बिना रिकर्सन के लिखा जाता है, तो यह जमा-जमाई जानकारी हमें ख़ुद सँभालनी पड़ती है। इसके लिए अपना एक स्टैक बनाया जाता है। इसीलिए पेड़ के ट्रैवर्सल जैसे काम बिना रिकर्सन के स्टैक से किए जाते हैं। क्यू FIFO है, वह लौटने का उल्टा क्रम नहीं दे सकता। लिंक्ड लिस्ट और ट्री सिर्फ़ ढाँचे हैं।
While recursion runs, the variables and return address of each call are saved on the system call stack. If we rewrite the same algorithm without recursion, that saved information has to be handled by us. So we build an explicit stack of our own. This is how tree traversals are written iteratively. A queue is FIFO and cannot give the reverse order that backtracking needs. A linked list or a tree is only a container here.
प्रश्न 10उत्तर + हल Tree
नीचे दिया गया कोड क्या करता है?

public void func(Tree root)

{

    func(root.left());

    func(root.right());

    System.out.println(root.data());

}
What does the following piece of code do?

public void func(Tree root)

{

    func(root.left());

    func(root.right());

    System.out.println(root.data());

}
  1. Aप्रीऑर्डर ट्रैवर्सल (Preorder traversal)Preorder traversal
  2. Bइनऑर्डर ट्रैवर्सल (Inorder traversal)Inorder traversal
  3. Cपोस्टऑर्डर ट्रैवर्सल (Postorder traversal)Postorder traversal
  4. Dलेवल ऑर्डर ट्रैवर्सल (Level order traversal)Level order traversal

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

हल / Solution
ट्रैवर्सल का नाम इस बात से तय होता है कि जड़ (root) का डेटा कब छापा जा रहा है। यहाँ पहले बायाँ उप-वृक्ष पूरा घूमा जाता है, फिर दायाँ, और छपाई सबसे आख़िर में होती है। बाएँ-दाएँ-जड़ का यही क्रम पोस्टऑर्डर कहलाता है। प्रीऑर्डर में छपाई सबसे पहले होती, इनऑर्डर में दोनों कॉलों के बीच में। लेवल ऑर्डर स्तर-दर-स्तर चलता है और उसके लिए रिकर्शन नहीं, क्यू चाहिए।
The name of a traversal depends on when the data of the root is printed. In this code the whole left subtree is visited first, then the whole right subtree, and printing happens at the very end. This left, right, root order is called postorder. In preorder the printing would come first, and in inorder it would sit between the two recursive calls. Level order moves level by level and needs a queue rather than recursion.
आगे के 10 प्रश्नों के उत्तर और हल app मेंFliQi Question Bank — अभ्यास, हल और आपकी प्रगति
App खोलिए
प्रश्न 13उत्तर app में Tree
बाइनरी सर्च ट्री के इनऑर्डर ट्रैवर्सल की विशेषता क्या है?
What is the speciality about the inorder traversal of a binary search tree?
  1. Aयह अनावर्धी क्रम में ट्रैवर्स करता हैIt traverses in a non increasing order
  2. Bयह बढ़ते क्रम में ट्रैवर्स करता हैIt traverses in an increasing order
  3. Cयह बेतरतीब ढंग से ट्रैवर्स करता हैIt traverses in a random fashion
  4. Dयह नोड की प्राथमिकता के आधार पर ट्रैवर्स करता हैIt traverses based on priority of the node
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 15उत्तर app में Stack
स्टैक की प्रविष्टियाँ "क्रमबद्ध" (ordered) होती हैं। इस कथन का अर्थ क्या है?
Entries in a stack are "ordered". What is the meaning of this statement?
  1. Aस्टैक का समूह छाँटा जा सकता हैA collection of stacks is sortable
  2. Bस्टैक की प्रविष्टियों की तुलना '<' क्रिया से की जा सकती हैStack entries may be compared with the '<' operation
  3. Cप्रविष्टियाँ लिंक्ड लिस्ट में रखी जाती हैंThe entries are stored in a linked list
  4. Dप्रविष्टि क्रमानुसार होती है, यानी एक-एक करकेThere is a Sequential entry that is one by one
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 16उत्तर app में Tree
बाइनरी सर्च ट्री के बारे में निम्नलिखित में से कौन-सा कथन ग़लत है?
Which of the following is false about a binary search tree?
  1. Aबायाँ बच्चा हमेशा अपने पैरेंट से छोटा होता हैThe left child is always lesser than its parent
  2. Bदायाँ बच्चा हमेशा अपने पैरेंट से बड़ा होता हैThe right child is always greater than its parent
  3. Cबाएँ और दाएँ उपवृक्ष भी बाइनरी सर्च ट्री होने चाहिएThe left and right sub-trees should also be binary search trees
  4. Dइनऑर्डर क्रम तत्वों को घटते क्रम में देता हैIn order sequence gives decreasing order of elements
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 18उत्तर app में Stack
एक स्टैक में पहले से ही पाँच तत्व हैं और स्टैक का आकार 5 है, अब एक और तत्व Push करने पर स्टैक ___________ हो जाता है
Pushing an element into stack already having five elements and stack size of 5, then stack becomes ___________
  1. AOverflow / ओवरफ़्लोOverflow
  2. BCrash / क्रैशCrash
  3. CUnderflow / अंडरफ़्लोUnderflow
  4. DUser flow / यूज़र फ़्लोUser flow
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
Senior Computer Instructor — Paper II DSA — topic-वार पूरा अभ्यासFliQi Question Bank app में