GATE Overflow - Recent questions tagged binary-search
https://gateoverflow.in/tag/binary-search
Powered by Question2AnswerBinary Search
https://gateoverflow.in/170721/binary-search
<p>In this given question <strong>I find all answers false </strong>because while implementing <strong>binary </strong><strong>seach</strong><strong> or tracing it for an example we need to follow same approach Right</strong>? if we are taking <strong>ceil for evaluation then it should be considered throughout and if we are taking floor accordingly it should be traced</strong>.Therefore applying both operating individually I find none of the options matching.
<br>
Correct Me If I am wrong here.
<br>
<img alt="" src="https://gateoverflow.in/?qa=blob&qa_blobid=7194659928028060266" style="float:left"></p>Algorithmshttps://gateoverflow.in/170721/binary-searchThu, 16 Nov 2017 08:40:05 +0000Binary search on two mutually exclusive arrays.
https://gateoverflow.in/166576/binary-search-on-two-mutually-exclusive-arrays
<p>There are two sorted list each of length $n$. An element to be searched in the both the lists. The lists are mutually exclusive. The maximum number of comparisons required using binary search is?
<br>
<br>
<strong>Their solution</strong> : $logn + logn = 2*logn = logn^{2}$.
<br>
<br>
<strong>My Solution</strong> : $min(logn_{1}, logn_{2}) = logn$ as $n1 = n2$. The intuition behind my solution is that we can do binary search in both the lists in parallel, we return from the search the moment we find the element.
<br>
<br>
<br>
<br>
So tell me whose solution is correct? Why my solution should be incorrect?</p>Algorithmshttps://gateoverflow.in/166576/binary-search-on-two-mutually-exclusive-arraysMon, 06 Nov 2017 02:02:13 +0000Self-doubt
https://gateoverflow.in/146285/self-doubt
Which of the following is exact recurrence relation for binary search (in terms of number of comparisons) ?<br />
<br />
1. T(n) = 2T(n/2) + 1<br />
<br />
2. T(n) = 2T(n/2) + 2<br />
<br />
Please specify relevant reasons.Algorithmshttps://gateoverflow.in/146285/self-doubtTue, 22 Aug 2017 06:53:39 +0000Modified Binary Search
https://gateoverflow.in/144599/modified-binary-search
Suppose the first step in binary search algorithm is changed to M = (9L+R)/10, we know that the complexity of binary search is log(n). What will be the complexity of modified search?<br />
<br />
a) log(n)<br />
<br />
b) n<br />
<br />
c) n$\log 9/10(n)$<br />
<br />
d) 2nlog(n)DShttps://gateoverflow.in/144599/modified-binary-searchWed, 16 Aug 2017 12:15:04 +0000Binary search
https://gateoverflow.in/142871/binary-search
How to get space complexity of binary search ..<br />
<br />
I am getting confusion in <br />
<br />
Space complexity = ip + extra (stack) <br />
<br />
And ip = nB ( why it is nB) ????? <br />
<br />
And extra = logn B <br />
<br />
So <br />
<br />
nB+ log n B = O(n) ...Algorithmshttps://gateoverflow.in/142871/binary-searchThu, 10 Aug 2017 04:03:12 +0000Binary Search
https://gateoverflow.in/135135/binary-search
<p><a rel="nofollow" href="https://gateoverflow.in/121046/binary-search">I/p - Sorted array of n element</a></p>
<p><a rel="nofollow" href="https://gateoverflow.in/121046/binary-search">O/p- find any two elements a and b such that (a+b)>1000</a></p>
<p><a rel="nofollow" href="https://gateoverflow.in/121046/binary-search">if lenear search is possible then go to Binary Search and Find time complexity ..?</a></p>Algorithmshttps://gateoverflow.in/135135/binary-searchWed, 28 Jun 2017 16:56:08 +0000Difference between finding Inorder Successor vs finding next using Inorder Traversal in BST
https://gateoverflow.in/134681/difference-between-finding-inorder-successor-finding-traversal
<h2> How is it possible that the time complexity of inorder traversal is O(n), because the time complexity of Inorder Successor in Binary Search Tree is O(log n), So the inorder traversal in BST for printing the numbers take O(n*logn) time for 'n' nodes???</h2>
<h3> </h3>Algorithmshttps://gateoverflow.in/134681/difference-between-finding-inorder-successor-finding-traversalSun, 25 Jun 2017 10:02:31 +0000Self doubt in Binary search Algo
https://gateoverflow.in/132037/self-doubt-in-binary-search-algo
<p>The average successful search time taken by binary search on a sorted array of 10 items?</p>
<p>(a) 2.6 (b) 2.7 (c) 2.8 (d) 2.9</p>
<p>Answer is 2.9</p>
<p>My doubt:- But when I am using log<sub>2</sub>n for n = 10 it is not equal to 2.9, and log<sub>2</sub>10 = 3.3219?</p>Algorithmshttps://gateoverflow.in/132037/self-doubt-in-binary-search-algoTue, 06 Jun 2017 03:38:05 +0000binary search
https://gateoverflow.in/121046/binary-search
I/p - array of n element in which untill some postion all are integer and afterward all are star (*)<br />
<br />
<br />
<br />
O/p- find the postion of 1st star (*)<br />
<br />
Hint - if lenear search is possible the go to BS<br />
<br />
Find time complexity ..?Algorithmshttps://gateoverflow.in/121046/binary-searchThu, 09 Mar 2017 10:21:45 +0000Time complexity to compute the sum of k smallest element in the binary search tree??
https://gateoverflow.in/114825/time-complexity-compute-smallest-element-binary-search-tree
<p><strong>Time complexity to compute the sum of k smallest element in the binary search tree??</strong></p>
<p>can we do it like this-</p>
<p>Start doing the inorder traversal of the binary search tree, it will give the elements in increasing order. Start the counter k=0. As we get the elements we increment the counter and then stop the traversal when count reaches k and sum the elements which we have got. Its time complexity will be O(h+k).</p>
<p>Am i right??</p>
<p>plzz plzz explain someone</p>Programminghttps://gateoverflow.in/114825/time-complexity-compute-smallest-element-binary-search-treeThu, 02 Feb 2017 14:42:04 +0000binary search
https://gateoverflow.in/80842/binary-search
Consider an array ‘A’ with 2m elements. The elements in odd position are sorted in non-increasing order that is A[1] >= A[3] >= A[5]......A[2m-1] The elements in even position are sorted in non-decreasing order, that is A[2]<= A[4] <= A[6].....A[2m]. Which of the following method is recommended for finding if a given number is in array?Algorithmshttps://gateoverflow.in/80842/binary-searchThu, 10 Nov 2016 11:00:28 +0000binary search
https://gateoverflow.in/80822/binary-search
Stack space used in binary search resursive implementation.Algorithmshttps://gateoverflow.in/80822/binary-searchThu, 10 Nov 2016 10:17:49 +0000#Algorithm
https://gateoverflow.in/78759/%23algorithm
Given a sorted array of distinct interger A[1...N] , you want to find out whether there is an index "i" for which A[i] =i . if this problem is solved using divide and conquer method,then find time complexity.Algorithmshttps://gateoverflow.in/78759/%23algorithmFri, 04 Nov 2016 11:22:59 +0000binary tree
https://gateoverflow.in/77029/binary-tree
<p><img alt="" src="https://gateoverflow.in/?qa=blob&qa_blobid=10819883219852282776"></p>Algorithmshttps://gateoverflow.in/77029/binary-treeWed, 26 Oct 2016 23:17:10 +0000Gatebook exam
https://gateoverflow.in/65147/gatebook-exam
<p>Consider the following exponential search algorithm(ES). The array of n elements have to be searched is divided in to logn parts. The ith part is from index <img alt="2^{i-1}" src="http://latex.codecogs.com/gif.latex?2%5E%7Bi-1%7D"> to<img alt="2^{i}" src="http://latex.codecogs.com/gif.latex?2%5E%7Bi%7D">. to search an element search all the parts one by one from left to right using binary search algorithm. What is the worst case complexity of above searching algorithm?</p>
<p> </p>
<p> </p>Programminghttps://gateoverflow.in/65147/gatebook-examSat, 27 Aug 2016 21:55:17 +0000Binary Search Tree
https://gateoverflow.in/64412/binary-search-tree
Suppose we do not have a parent pointer in the nodes of a search tree, only left-child and right-child. Which of the following operations can be computed in time $O(\log n)$ for a balanced search tree?<br />
<br />
1- find, insert, delete, but not min, max, pred, succ<br />
2- find, insert, delete, min, max, but not pred, succ<br />
3- find, insert, delete, pred, succ but not min, max<br />
4- All of find, insert, delete, min, max, pred, succAlgorithmshttps://gateoverflow.in/64412/binary-search-treeTue, 23 Aug 2016 10:53:54 +0000Binary Tree
https://gateoverflow.in/58227/binary-tree
<p>What is the difference between</p>
<p><strong>Binary Tree </strong>and <strong>Almost complete Binary tree</strong> and <strong>complete Binary</strong> <strong>Tree </strong>and <strong>full Binary Tree</strong> and <strong>Binary search Tree</strong> and <strong>Balanaced Binary Search Tree. </strong></p>
<p><strong>Diagram would be appriciated otherwaise write 2-3 basic difference .</strong></p>
DShttps://gateoverflow.in/58227/binary-treeSat, 16 Jul 2016 03:34:25 +0000Which search sequence is not possible in binary search tree?
https://gateoverflow.in/57543/which-search-sequence-is-not-possible-in-binary-search-tree
<pre>
<span style="font-family:tahoma,geneva,sans-serif;">A binary search tree is used to locate the number 43.
Which of the following probe sequence is not possible?
(A)61 52 14 17 40 43
(B)23 5O 40 60 43
(C) 10 65 31 48 37 43
(D)81 61 52 14 41 43</span></pre>
Programminghttps://gateoverflow.in/57543/which-search-sequence-is-not-possible-in-binary-search-treeTue, 12 Jul 2016 17:04:24 +0000Binary search
https://gateoverflow.in/53126/binary-search
If the binary search algorithm determines that the scanned argument is in upper half of the array,which of the following statement will set the appropriate variable to the appropriate value.<br />
<br />
A) startsub= middlesub-1;<br />
<br />
B) startsub=middlesub+1;<br />
<br />
C)stopsub=middlesub-1;<br />
<br />
D)stopsub=middlesub+1;DShttps://gateoverflow.in/53126/binary-searchFri, 24 Jun 2016 11:18:40 +0000ISRO2011-62
https://gateoverflow.in/52839/isro2011-62
<p>The average depth of a binary search tree is</p>
<ol style="list-style-type: upper-alpha;">
<li>$O(n^{0.5})$</li>
<li>$O(n)$</li>
<li>$O(\log n)$</li>
<li>$O(n \log n)$</li>
</ol>
DShttps://gateoverflow.in/52839/isro2011-62Thu, 23 Jun 2016 11:11:17 +0000Linked List
https://gateoverflow.in/50828/linked-list
Linked Lists are not suitable for _____.<br />
<br />
A. Binary Search<br />
B. Polynomial Manipulation<br />
C. Insertion<br />
D. Radix SortDShttps://gateoverflow.in/50828/linked-listThu, 16 Jun 2016 12:33:34 +0000ISRO2007-59
https://gateoverflow.in/49626/isro2007-59
<p>The time taken by binary search algorithm to search a key in a sorted array of n elements is</p>
<ol style="list-style-type: upper-alpha;">
<li>$O\: (\log_2 \: n)$</li>
<li>$O \: (n)$</li>
<li>$O \: (n \: \log_2 \: n)$</li>
<li>$O \: (n^2)$</li>
</ol>
Algorithmshttps://gateoverflow.in/49626/isro2007-59Fri, 10 Jun 2016 11:36:24 +0000Linked list
https://gateoverflow.in/42112/linked-list
Why linked list not suitable for binary search?DShttps://gateoverflow.in/42112/linked-listMon, 04 Apr 2016 17:11:45 +0000[ME Test Series] When searching for the key value 50 in a binary search tree, node containing the
https://gateoverflow.in/32671/series-when-searching-value-binary-search-tree-containing
When searching for the key value 50 in a binary search tree, node containing the key values 10, 30, 40, 70, 90, 120, 150, 175 are traversed, in any order. The number of different orders passing in which these keys values can occur on the search path from the root to node containing the value 50 are ________.DShttps://gateoverflow.in/32671/series-when-searching-value-binary-search-tree-containingSun, 27 Dec 2015 15:57:07 +0000#doubt on heaps and binary search
https://gateoverflow.in/31046/%23doubt-on-heaps-and-binary-search
Consider the process of inserting an element into a max heap, where the max heap is represented by an array.Suppose we perform a binary search on the path from the new leaf to the root to find the position for newly inserted element, the number of comparisons performed is? # i m getting as O(logn) as upon applying binary search we wud compare O(logn) elements(neighbours and its own root only) plz clr my confusionAlgorithmshttps://gateoverflow.in/31046/%23doubt-on-heaps-and-binary-searchWed, 16 Dec 2015 07:35:17 +0000Binary Search - Average Number of Comparisons.
https://gateoverflow.in/29654/binary-search-average-number-of-comparisons
<blockquote>
<p><em><span style="font-size:14px;"><span style="color: rgb(0, 0, 0); font-family: Verdana, Arial, Helvetica, sans-serif; line-height: 17px; text-align: justify;">Let you are given an array of nine elements in increasing order. If you want to implement binary search on the given array of element then the number of comparisons per successful search on an average will be:</span></span></em></p>
</blockquote>
<hr>
<p><span style="color: rgb(0, 0, 0); font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 14px; line-height: 17px; text-align: justify;">Average is 2.78,</span></p>
<p><span style="color: rgb(0, 0, 0); font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 14px; line-height: 17px; text-align: justify;">should I answer this question with or without rounding off 2.78, as number of comparisons is an integral value?</span></p>
<p style="text-align: justify;"> </p>
Algorithmshttps://gateoverflow.in/29654/binary-search-average-number-of-comparisonsSat, 05 Dec 2015 18:43:25 +0000Average number of comparisons in a binary search on a sorted array of 10 consecutive int. starting from 1?
https://gateoverflow.in/16831/average-number-comparisons-binary-search-consecutive-starting
Algorithmshttps://gateoverflow.in/16831/average-number-comparisons-binary-search-consecutive-startingTue, 15 Sep 2015 17:04:34 +0000ISRO2014-28
https://gateoverflow.in/16124/isro2014-28
<p>Suppose there are 11 items in sorted order in an array. How many searches are required on the average, if binary search is employed and all searches are successful in finding the item?</p>
<ol style="list-style-type: upper-alpha;">
<li>3.00 </li>
<li>3.46 </li>
<li>2.81 </li>
<li>3.33</li>
</ol>
Algorithmshttps://gateoverflow.in/16124/isro2014-28Sat, 05 Sep 2015 19:13:21 +0000When is searching $O(\log n)$ in an array?
https://gateoverflow.in/14320/when-is-searching-%24o-log-n-%24-in-an-array
<p>Consider the problem of searching an element $x$ in an array $\text{arr}$ of size $n$. When can the problem can be solved in $O(\log n)$ time?</p>
<ol>
<li>Array is sorted</li>
<li>Array is sorted and rotated by $k$. $k$ is given to you and $k \leq n$.</li>
<li>Array is sorted and rotated by $k$. $k$ is NOT given to you and $k \leq n$</li>
<li>Array is not sorted</li> </ol>
<div> </div>
<div>(A) 1 Only
<br> (B) 1 & 2 only
<br> (C) 1, 2 and 3 only
<br> (D) 1, 2, 3 and 4
<br>
<br> I am clear with 1 and 2 option but not getting about option 3.</div>
<div>
<div id="u_jsonp_7_2c"> </div> </div>Algorithmshttps://gateoverflow.in/14320/when-is-searching-%24o-log-n-%24-in-an-arrayFri, 31 Jul 2015 05:04:17 +0000