Skip to main content

Questions tagged [binary-search]

Use this tag for code that implements a binary search.

8 votes
5 answers
1k views

I tried solving the LeetCode question like many others, trying to incorporate the O(n) time complexity requirement. Squares of a Sorted Array Given an integer array ...
Littlejacob2603's user avatar
3 votes
3 answers
206 views

Write an efficient function in the Python language called SmartSearch. This function will receive a sorted arr array of integers of size \$n\$ containing at the ...
SHOVAL's user avatar
  • 61
5 votes
1 answer
245 views

The bisect module can only find the index to insert an element. I created a simple class based on the bisect module for precise searching and covered all the edge cases that came to mind with tests. ...
Aycon's user avatar
  • 225
3 votes
1 answer
203 views

Since initial question Increasing binary search for mismatch in sorted range contained defects in code and can confuse the readers, here is the updated version of the question. Is the code below ...
Damir Tenishev's user avatar
3 votes
2 answers
253 views

I've been working on an assignment that involves optimizing a duplicate finding algorithm for sorted arrays, and I'd like to get your thoughts on the implementation. Here's the code I've come up with: ...
Bryan C's user avatar
  • 31
4 votes
1 answer
358 views

...
Hansoko's user avatar
  • 153
9 votes
3 answers
2k views

I've implemented the Egg Drop Problem using Python. As described in the code, I'm trying to find the highest floor of a 102-story building from which I could drop an egg without it breaking. The ...
Muhammed Abiola's user avatar
4 votes
3 answers
1k views

Could you advise on this binary search implementation? ...
acd's user avatar
  • 107
1 vote
1 answer
144 views

I have written code as below: ...
Szyszka947's user avatar
2 votes
1 answer
150 views

I'm struggling a bit with a USACO silver question using Python: http://usaco.org/index.php?page=viewproblem2&cpid=992. The question provides an unsorted list of numbers (...
Luke's user avatar
  • 21
3 votes
1 answer
2k views

There are solutions e.g. list.OrderBy(item => Math.Abs(number - item)).First() or ...
nop's user avatar
  • 819
3 votes
2 answers
449 views

This is my task: Each line in the file can be one of the following: Updates to the limit order book in the following format: ...
Данил Денк's user avatar
3 votes
2 answers
1k views

I wrote a non recursive binary search implementation in C, for this time I think there are no bugs. Here's the code: ...
manungsa's user avatar
  • 107
4 votes
3 answers
302 views

I have this typical code interview type problem. Suppose you have a stick of length n. You make X cuts in the stick at places x1, x2, x3 and so on. For every cut in X cuts you need to print the length ...
Some nerd who does not have a 's user avatar

15 30 50 per page
1
2 3 4 5
21