# Questions tagged [binary-search]

Use this tag for code that implements a binary search.

16 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
560 views

### Red-black tree appears to be slower than std::multimap

I've written a red-black tree in C as an exercise. The tree works and it is not bad, but it is about 10% slower than std::multimap from libstdc++ which I'm ...
91 views

### Subtracting elements of datasets of an HDF5 file

I am trying to solve the following problem: Input: Input is two arrays (Nx4, sorted in column-2) stored in datasets-1 and 2 in HDF5 file (input.h5). N is huge (...
• 61
447 views

### Persistent segment tree

I'm trying to solve this problem. Given a sequence $B=B_0,B_1,\ldots,B_{N−1}$ for each query $(P,K)$, find the minimum $S$ s.t. there are at least $K$ entries in $B$ that satisfies ...
• 358
70 views

### Array Search Algorithm

Recently, I've been experimenting with an array searching algorithm that I'm not sure I've seen anywhere (minor references here). I'm still not fully-learned on how to state the efficiency of what I'...
• 141
2k views

### AVL Tree with delete method in Python 3

Just a general code review. I'm looking for my first developer job so anything constructive is awesome. Please, and thank you very much. I've written this implementation as an exercise and to add to ...
• 373
68 views

### Basic Binary Tree in Go

As an exercise I have written a basic binary tree implementation in Go. Tree struct: ...
• 213
532 views

### BST remove implementation

As practise, I implemented a BST and also the remove() method, but I figured I always have to check if the node being deleted is coming from the left child or the ...
• 31
258 views

### Find Single Element in a Sorted Array, from LeetCode

The problem quoted: https://leetcode.com/problems/single-element-in-a-sorted-array/ Given a sorted array consisting of only integers where every element appears exactly twice except for one element ...
• 391
48 views

### Find target in sorted array pivoted at some unknown point in O(log n)

You are given an array sorted in ascending order which is rotated at some pivot unknown to you beforehand. Find your target in $O(log n)$ which means it should be a binary search. If the value ...
• 586
969 views

### Three sum using binary search

Given an array and a value, find all the triplets in the array whose sum is equal to the given value. For example, if the given array is {12, 3, 4, 1, 6, 9} and the ...
• 345
571 views

### Computing the square root of a number using binary search

This is implemented in MIPS assembly. I've hard-coded the initial guess, as I haven't figured out how to allow the user to input a negative or non-negative integer to then display the result back to ...
• 21
1 vote
109 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 ...
• 11
1 vote
62 views

### BST range search

I'd like some input on my implementation of bst-range, which follows below. Before we can get to bst-range, we first need some setup code to build the BST. (You ...
• 493
1 vote
3k views

### Binary Search Implementation using template

This post is follow up of this, suggested by @loki-astari which can be found here. Any further improvement is welcome. Binary_Search.h ...
• 337