पहले 10 प्रश्नों के उत्तर और हल यहीं खुले हैं; बाक़ी 20 के उत्तर और हल FliQi Question Bank app में।
भाषा
प्रश्न 1उत्तर + हल
ऐरे में मान ढूँढ़ने के लिए बाइनरी सर्च एल्गोरिथम में निम्नलिखित में से कौन सा कथन उपयोग होता है?
Which of the following statements is used in the binary search algorithm to find value of the array?
Aमिडिल इंडेक्स = (स्टार्ट इंडेक्स + स्टॉप इंडेक्स)/2Middle Index = (Start Index + Stop Index)/2
Bमिडिल इंडेक्स = (स्टार्ट इंडेक्स − स्टॉप इंडेक्स)/2Middle Index = (Start Index − Stop Index)/2
Cमिडिल इंडेक्स = (स्टार्ट इंडेक्स)/2 + स्टॉप इंडेक्सMiddle Index = (Start Index)/2 + Stop Index
Dमिडिल इंडेक्स = (स्टार्ट इंडेक्स)/2 − स्टॉप इंडेक्सMiddle Index = (Start Index)/2 − Stop Index
सही उत्तर / Answer: (A)
हल / Solution
बाइनरी सर्च को हर क़दम पर बीच की जगह चाहिए, और दो सिरों के बीच का स्थान उनका औसत होता है — इसलिए मिडिल इंडेक्स = (स्टार्ट + स्टॉप)/2। जैसे स्टार्ट 0 और स्टॉप 8 हो तो मिडिल 4 आता है, जो ठीक बीच है। अंतर वाला सूत्र (स्टार्ट − स्टॉप)/2 ऋणात्मक मान दे देता है। बाक़ी दो सूत्र स्टॉप इंडेक्स को जोड़ या घटा देते हैं, इसलिए उनका नतीजा सूची की सीमा से भी बाहर जा सकता है।
Binary search needs the middle position at every step, and the place halfway between two ends is simply their average, so the middle index equals start plus stop, divided by two. With start 0 and stop 8 the middle comes to 4, which is exactly in the middle. The difference form would give a negative value. The last two forms add or subtract the stop index, so their result can even fall outside the bounds of the list.
प्रश्न 2उत्तर + हल
डेटा की वह विशेषता, जिसका उपयोग बाइनरी सर्च करती है पर लीनियर सर्च नहीं, कौन सी है?
Characteristic of the data that binary search uses but the linear search ignores is
Aसूची के मदों का क्रम (order)order of the elements of the list
Bसूची की लंबाईlength of the list
Cसूची का अधिकतम मानmaximum value in the list
Dडेटा मानों का माध्य (mean)mean of data values
सही उत्तर / Answer: (A)
हल / Solution
बाइनरी सर्च बीच वाले मद से तुलना करके यह तय करती है कि आगे किस आधे हिस्से में देखना है। यह फ़ैसला तभी ठीक बैठता है जब मद पहले से क्रम में लगे हों, इसलिए क्रम (order) ही वह विशेषता है जिसका वह उपयोग करती है। लीनियर सर्च एक-एक मद देखती है, उसे क्रम से कोई मतलब नहीं। सूची की लंबाई दोनों को पता होती है, और अधिकतम मान या माध्य (mean) की खोज में कहीं ज़रूरत नहीं पड़ती।
Binary search compares with the middle item and from that decides which half to look in next. This decision only works if the items are already in order, so the order of the elements is the property it relies on. Linear search checks the items one by one and cares nothing about order. The length of the list is known to both methods, and neither the largest value nor the mean of the values is needed for searching at all.
प्रश्न 3उत्तर + हल
बाइनरी सर्च एल्गोरिथम का क्रम (order) है —
The order of the binary search algorithm is
An
Bn2
Cn log n
Dlog n
सही उत्तर / Answer: (D)
हल / Solution
बाइनरी सर्च हर तुलना के बाद बचा हुआ हिस्सा आधा कर देती है, इसलिए क़दमों की गिनती इस बात से निकलती है कि n को आधा करते-करते 1 तक पहुँचने में कितनी बार बाँटा — वही log n है। जैसे 1024 मदों में 1024, 512, 256 … 1 तक लगभग 10 क़दम लगते हैं। n लीनियर सर्च का क्रम है। n log n और n2 क्रमबद्धता विधियों के क्रम हैं, खोज के नहीं।
Binary search halves the remaining range after each comparison, so the number of steps is just the number of times n must be halved to reach 1, which is log n. Among 1024 items the run goes 1024, 512, 256 and so on down to 1, about ten steps in all. The order n belongs to linear search, which cannot drop half the data, while n log n and n squared are orders of sorting methods.
प्रश्न 4उत्तर + हल
निम्नलिखित में से किस काम के लिए लिंक्ड लिस्ट (linked list) उपयुक्त डेटा स्ट्रक्चर नहीं है?
For which of the following, the data structure linked list is not suitable?
Aइंसर्शन सॉर्ट (insertion sort)Insertion sort
Bरेडिक्स सॉर्ट (radix sort)Radix sort
Cबाइनरी सर्च (binary search)Binary search
Dबहुपद की गणना (polynomial manipulation)Polynomial manipulation
सही उत्तर / Answer: (C)
हल / Solution
बाइनरी सर्च को हर क़दम पर बीच वाले मद तक सीधे पहुँचना होता है, यानी सीधी पहुँच (random access) चाहिए। लिंक्ड लिस्ट में गाँठें स्मृति में बिखरी होती हैं, इसलिए बीच तक पहुँचने में ही O(n) समय लगता है और आधा-आधा काटने का फ़ायदा ख़त्म हो जाता है। इंसर्शन सॉर्ट में बस सूचक (pointer) बदलते हैं, रेडिक्स सॉर्ट में अंकों की सूचियाँ बनती हैं, और बहुपद के पद घटते-बढ़ते रहते हैं — इन तीनों में लिंक्ड लिस्ट सुविधा देती है।
Binary search has to reach the middle item directly at every step, which means it needs random access. In a linked list the nodes lie scattered in memory, so merely reaching the middle costs time of the order n and the gain of halving the range is lost. Insertion sort only has to relink pointers, radix sort builds lists of buckets, and a polynomial keeps changing its number of terms, so for those three a linked list is handy.
प्रश्न 5उत्तर + हल
किसी क्रमित (sorted) ऐरे में दिए गए मद को सबसे कम तुलनाओं में कौन सी खोज तकनीक ढूँढ़ लेती है?
Which of the following search techniques finds the given item in a sorted array with the fewest comparisons?
Aलीनियर सर्च (linear search)linear search
Bबाइनरी सर्च (binary search)binary search
Cहैशिंग (hashing)hashing
Dये सभीAll of these
सही उत्तर / Answer: (B)
हल / Solution
बाइनरी सर्च हर तुलना के बाद बचा हुआ हिस्सा आधा कर देती है, इसलिए 1024 मदों में भी लगभग 10 तुलनाओं में काम हो जाता है — यही 'बाँटो और जीतो' का फ़ायदा है। लीनियर सर्च को सबसे ख़राब हालत में n तुलनाएँ करनी पड़ती हैं। हैशिंग तेज़ है, पर उसे अलग हैश तालिका (hash table) चाहिए; सादे क्रमित ऐरे पर वह लग ही नहीं सकती। तीनों की गिनती अलग है, इसलिए 'ये सभी' भी ग़लत है।
Binary search halves the remaining range after every comparison, so even among 1024 items the work is done in about ten comparisons; that is the gain of divide and conquer. Linear search may need n comparisons in the worst case. Hashing is fast, but it needs a hash table of its own and cannot be applied to a plain sorted array at all. Since the three counts differ, the option 'All of these' cannot hold either.
प्रश्न 6उत्तर + हल
n लंबाई की लिंक्ड लिस्ट (linked list) में किसी मद को खोजने में कितना समय लगता है?
What is the time required to search an element in a linked list of length n?
AO(log2 n)
BO(n)
CO(1)
DO(n2)
सही उत्तर / Answer: (B)
हल / Solution
लिंक्ड लिस्ट में गाँठें (nodes) स्मृति में लगातार नहीं पड़ी होतीं; हर गाँठ तक पहुँचने के लिए पिछली गाँठ का सूचक (pointer) पकड़ना पड़ता है। इसलिए खोज सिर पहली गाँठ से शुरू होकर एक-एक करके आगे बढ़ती है और सबसे ख़राब हालत में पूरी लिस्ट देखनी पड़ती है — समय O(n)। O(1) तभी मिलता जब सीधी पहुँच (random access) होती, जैसे ऐरे में। O(log2 n) के लिए बीच वाली गाँठ पर कूदना ज़रूरी है, जो यहाँ संभव नहीं।
In a linked list the nodes do not lie next to each other in memory; each node is reached only through the pointer held by the one before it. So a search starts at the head and moves forward node by node, and in the worst case the whole list is seen, giving time of the order n. Constant time would need random access, as an array has, and log n time a jump to the middle node.
प्रश्न 7उत्तर + हल
n मदों वाले ऐरे पर लीनियर सर्च एल्गोरिथम की समय जटिलता (time complexity) क्या होती है?
What is the time complexity of linear search algorithm over an array of n elements?
AO(log2 n)
BO(n)
CO(n log2 n)
DO(n2)
सही उत्तर / Answer: (B)
हल / Solution
लीनियर सर्च हर मद को एक-एक करके जाँचती है। जो मद ऐरे के आख़िर में हो, या मौजूद ही न हो, उसके लिए पूरे ऐरे पर घूमना पड़ता है — यानी सबसे ख़राब हालत में n तुलनाएँ। इसलिए समय जटिलता O(n) है। O(log2 n) बाइनरी सर्च की है, जो हर क़दम पर आधा हिस्सा छोड़ देती है। O(n log2 n) और O(n2) क्रमबद्धता के आँकड़े हैं, खोज के नहीं।
Linear search tests the items one at a time. If the wanted item sits at the end of the array, or is missing altogether, the whole array has to be walked, which means n comparisons in the worst case. So the time complexity is of the order n. The figure log n belongs to binary search, which drops half the range at each step, while n log n and n squared are costs of sorting methods.
प्रश्न 8उत्तर + हल
......... में हम ऐरे के हर मद को एक-एक करके क्रम से देखते हैं और जाँचते हैं कि वही वांछित मद है या नहीं।
In ........, we access each element of an array one by one sequentially and see whether it is desired element or not.
Aबाइनरी सर्च (binary search)binary search
Bलीनियर सर्च (linear search)linear search
Cहैशिंग (hashing)hashing
Dउपरोक्त सभीAll of the above
सही उत्तर / Answer: (B)
हल / Solution
लीनियर सर्च (linear search) में ऐरे के मद शुरू से एक-एक करके देखे जाते हैं, और जो चाहिए वह मिलते ही खोज रुक जाती है। जैसे 5, 10, 15, 20 में 15 ढूँढ़ने पर पहले 5, फिर 10, फिर 15 जाँचे जाते हैं। यह सबसे सरल तरीक़ा है और क्रमित तथा बेतरतीब दोनों डेटा पर चलता है। बाइनरी सर्च बीच वाले मद से शुरू होती है और हैशिंग सीधे जगह निकालती है — दोनों एक-एक करके नहीं चलतीं।
In linear search the items of the array are looked at one after another from the start, and the hunt stops as soon as the wanted item turns up. To find 15 in 5, 10, 15, 20 you check 5, then 10, then 15. It is the simplest method and works on both sorted and unsorted data. Binary search begins at the middle item and hashing jumps straight to a slot, so neither moves one by one.
प्रश्न 9उत्तर + हल
......... मदों की सूची में किसी एक मद को ढूँढ़ने की प्रक्रिया है, चाहे सूची किसी क्रम में लगी हो या बेतरतीब हो।
......... is a process of finding an element within the list of elements sorted in any order or randomly.
Aखोज (searching)Searching
Bक्रमबद्धता (sorting)Sorting
Cविलयन (merging)Merging
Dव्यवस्थापन (arranging)Arranging
सही उत्तर / Answer: (A)
हल / Solution
किसी सूची में एक ख़ास मद को ढूँढ़ने के काम को खोज (searching) कहते हैं। इसका मक़सद यह जानना है कि वह मद मौजूद है या नहीं, और है तो किस जगह पर। लीनियर सर्च बेतरतीब सूची पर भी चल जाती है, जबकि द्विभाजन खोज (binary search) के लिए सूची क्रमित होनी चाहिए। क्रमबद्धता (sorting) मदों को क्रम में लगाती है, विलयन (merging) दो सूचियों को जोड़ता है, और 'व्यवस्थापन' कोई अलग मानक क्रिया नहीं है।
Looking for one particular item inside a list is called searching. Its aim is to learn whether the item is present at all and, if it is, at which position. Linear search works even on a random list, while binary search needs the list to be sorted first. Sorting instead puts items in order, merging joins two lists into one, and arranging is not a separate standard operation on a data structure.
प्रश्न 10उत्तर + हल
बाइनरी ट्री सॉर्ट (binary tree sort) की कमियाँ किस विधि से दूर होती हैं?
The drawbacks of the binary tree sort are remedied by the
Aलीनियर सॉर्ट (linear sort)linear sort
Bक्विक सॉर्ट (quick sort)quick sort
Cहीप सॉर्ट (heap sort)heap sort
Dइंसर्शन सॉर्ट (insertion sort)insertion sort
सही उत्तर / Answer: (C)
हल / Solution
बाइनरी ट्री सॉर्ट की कमज़ोरी यह है कि मद पहले से क्रमित आएँ तो ट्री एक लंबी लड़ी बन जाता है और समय O(n2) तक चढ़ जाता है; हर गाँठ के दो सूचक (pointer) रखने की जगह भी लगती है। हीप सॉर्ट दोनों कमियाँ हटाता है — वह पूर्ण बाइनरी ट्री (हीप) को ऐरे में रखता है, इसलिए ट्री बेढब नहीं होता और समय हर हालत में O(n log n) रहता है। क्विक सॉर्ट की ख़राब हालत ख़ुद O(n2) है।
The weak point of binary tree sort is that data arriving already sorted turns the tree into one long chain, pushing the time towards n squared, and each node also costs space for two pointers. Heap sort removes both faults: it keeps a complete binary tree inside the array itself, so the shape never degenerates and the time stays n log n in every case. Quick sort is no cure, since its own worst case is still n squared.
आगे के 20 प्रश्नों के उत्तर और हल app मेंFliQi Question Bank — अभ्यास, हल और आपकी प्रगति
वह सॉर्ट, जो बार-बार सूची में घूमकर पहले मद को अपने से छोटे किसी मद से बदल देता है और फिर अगले मद से यही दोहराता है, कौन है?
A sort which iteratively passes through a list to exchange the first element with any element less than it and then repeats with a new first element is called