binary-search Questions
9
Solved
I need a binary search algorithm that is compatible with the C++ STL containers, something like std::binary_search in the standard library's <algorithm> header, but I need it to return the it...
Vish asked 15/1, 2009 at 10:34
4
Solved
How good/fast is Excel VBA's Find vs. binary search? My platform is Office 11|2003 and I'll be searching for strings against Column A on three sheets of values. Total number of rows ~140,000
If wo...
Ashur asked 7/12, 2009 at 2:10
3
Solved
C++11 includes the algorithm std::partition_point(). However for all the cases I have tried it gives the same answer as std::lower_bound(). The only difference being the convenient T& value par...
Walrus asked 26/6, 2018 at 19:24
2
Whenever I perform binary search iteratively I am always confused about whether I should use while (low < high) or while(low <= high).
Although both will work, can someone tell me what might...
Grazynagreabe asked 7/2, 2016 at 17:8
3
Solved
I am looking for a built-in Ruby method that has the same functionality as index but uses a binary search algorithm, and thus requires a pre-sorted array.
I know I could write my own implementatio...
Reactor asked 29/12, 2011 at 19:28
11
What is the difference between Linear search and Binary search?
Insert asked 31/3, 2009 at 6:21
5
Solved
I want to do a binary search in python:
def binarySearch(data, val):
Where data is a sorted array and value is the value being searched for. If the value is found, I want to return the index (su...
False asked 15/5, 2014 at 14:58
2
Solved
I have a sorted (ascending) array of real values, call it a (duplicates possible). I wish to find, given a range of values [x, y], all indices of values (i) for which an index j exists such that:
...
Masakomasan asked 18/2, 2018 at 9:28
2
Question:
This is a problem from LeetCode:
Given an integer array, return the k-th smallest distance among all
the pairs. The distance of a pair (A, B) is defined as the absolute
difference b...
Fleabitten asked 11/2, 2018 at 19:16
3
Solved
Finding the maximum or minimum value in a sequence that increases montonically and then decreases monotonically can be done in O(log n).
However, if i want to check if a number exists in such a se...
Politicize asked 18/7, 2012 at 7:16
6
Solved
Recently I came across one interesting question on linked list. Sorted singly linked list is given and we have to search one element from this list.
Time complexity should not be more than O(log ...
Rondi asked 12/3, 2011 at 6:43
7
Solved
The problem is to extend the binary search algorithm to find all occurrences of a target value in a sorted array in the most efficient way.
Concretely speaking, the input of the algorithm is (1) a...
Huskamp asked 8/2, 2010 at 0:13
10
Solved
I've been tasked with creating a method that will print all the indices where value x is found in a sorted array.
I understand that if we just scanned through the array from 0 to N (length ...
Bianca asked 2/11, 2012 at 14:48
3
Solved
If i construct a binary search tree adding the following values in order:
10, 7, 16, 12, 5, 11, 2, 20, 1, 14
I get a tree of height 5. Is there a method (other than trial and error) that I can ...
Auricula asked 11/5, 2012 at 11:15
3
Solved
The great findInterval() function in R uses left-closed sub-intervals in its vec argument, as shown in its docs:
if i <- findInterval(x,v), we have v[i[j]] <= x[j] < v[i[j] + 1]
If I ...
Sleeve asked 20/11, 2012 at 21:54
9
Solved
I'm looking at List and I see a BinarySearch method with a few overloads, and I can't help wondering if it makes sense at all to have a method like that in List?
Why would I want to do a binary se...
Fisk asked 15/7, 2010 at 13:40
8
Solved
I am struggling to port a Perl program to Java, and learning Java as I go. A central component of the original program is a Perl module that does string prefix lookups in a +500 GB sorted text file...
Medulla asked 10/4, 2009 at 2:39
2
Solved
I'm reading different materials about Binary search, and it's not clear to me is it a greedy binary (which looks to me like it's not) or, CAN it be a greedy algorithm with some specific implementat...
Oppressive asked 25/7, 2017 at 12:40
2
Solved
It is easy to find an integer with binary search even if it can be arbitrarily large: first guess the order of magnitude, then keep dividing the interval.
This answer describes how to find an arbit...
Koffman asked 8/7, 2017 at 21:49
4
It is a problem from C++ primer fifth edition problem 3.26, I don't know the difference between them ?
May be the second one can avoid overflow.
Schmaltzy asked 8/1, 2014 at 14:54
2
Solved
If binarySearch method requires you to sort your array before passing it as parameter to the method call, why not do a sort in the binarySearch method?
Gibberish asked 16/12, 2014 at 19:3
5
Solved
I gave a shot at solving the Hackerland Radio Transmitters programming challange.
To summarize, challenge goes as follows:
Hackerland is a one-dimensional city with n houses, where each house i...
Budd asked 25/4, 2017 at 20:36
2
Solved
In binary search, we usually have low and high variables and typically there is a while loop that tests if low <= high, as shown in this code (from Wikipedia):
int SortedArray[max] = {....}
i...
Dene asked 28/5, 2017 at 19:51
8
Solved
I have been using my time off university to practice Java through coding algorithms. One of the algorithms I coded was the binary search:
public class BinarySearch {
private static int list[] = ...
Japonica asked 25/9, 2013 at 18:39
1
Solved
Given a sorted array of integers with possibly duplicates, how do you find an index i such that A[i]=i
This is a problem in one of the programming books I read (Cracking the code interview). The s...
Vaughan asked 4/3, 2017 at 18:49
© 2022 - 2024 — McMap. All rights reserved.