Skip to main content

Questions tagged [binary-search]

Use this tag for code that implements a binary search.

2 votes
3 answers
160 views

Creating a search function

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
  • 51
5 votes
1 answer
188 views

Testing binary search module, based on bisect

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
  • 153
3 votes
1 answer
130 views

Incremental upper bound in sorted range

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
202 views

Counting duplicate elements in two sorted arrays

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
306 views

K&R exercise 3-1

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

Optimizing the Egg Drop Problem implemented with Python

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

C++ Binary Search

Could you advise on this binary search implementation? ...
acd's user avatar
  • 107
-2 votes
2 answers
141 views

Lower-Bound algorithm getting Time Limit Exceeded

...
Shakhawat Hossain SHIHAB's user avatar
1 vote
1 answer
106 views

Binary search of 2D matrix

I have written code as below: ...
Szyszka947's user avatar
1 vote
0 answers
112 views

USACO Silver "Wormhole Sort" solver

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 (cows) and a number of ...
Luke's user avatar
  • 11
3 votes
1 answer
2k views

Find closest value in a big list

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

Implementation of a market that matches bids to offers

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

Non recursive binary search in C

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
269 views

Increase efficiency of stick cutting algorithm

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
0 votes
1 answer
37 views

Improving time complexity for codechef Que [closed]

Question Link. Binary Search and Two Pointers related question. For the above-mentioned question, In other people's solutions, people get AC with a binary search solution. However, I get TLE with ...
High On Math's user avatar

15 30 50 per page
1
2 3 4 5
21