Binary search is an efficient algorithm for finding a key in a sorted array. It runs in O(log n) time.
1
vote
1answer
56 views
Binary Search Feedback
I have written a binary search algorithm, but it seems to be a bit different than other peoples that I've seen. I was hoping that the community could give me some feedback as to whether or not I'm ...
1
vote
2answers
67 views
Check if a Binary Tree <String> is aBinary Search Tree
i'm understanding the question but wanna make sure if my implementation is correct or not =|
The Q is :
Write a method that accepts as its argument a BinaryTree object and returns true if the ...
3
votes
0answers
88 views
Wrote high-concurrency dictionary in C, would like peer review
Project Repository
Details to know before looking at code (look for flaws in my approach before looking for code flaws)
I have include/*.h as the headers meant to be used by consumers of the ...
0
votes
1answer
49 views
Creating an Array of Linked Lists from a BST
Question
Given a binary search tree, design an algorithm which creates a linked list of all the nodes at each depth (eg, if you have a tree with depth D, you’ll have D linked lists)
Here is my ...
1
vote
2answers
108 views
How can this code become cleaner and less error prone? Especially the binary search part
How could this code become cleaner?
I think that the way I handle the interfaces and binary search could be improved.
I am trying to understand how to structure such a code 9and usage of APIs) in a ...
2
votes
1answer
206 views
Returning Binary Search Tree Nodes in Zig Zag manner
I tried to implement an answer for the algorithm question given below. I implemented two different solutions. I couldn't decide which one is better. ( Maybe none )
Note: Node class and ZigZag ...
1
vote
0answers
82 views
Binary search algorithm for non-overlapping time spans and possible gaps
I have a data structure, containing time span nodes, with the following properties:
Nodes are sorted ascending
Time spans will not overlap, but may have gaps between them
Each node will have a start ...
0
votes
1answer
61 views
Errors with binary search in Haskell
I just learned about Maybe in Haskell, so I decided to try to use it with a binary search.
Here's the function:
binarySearch :: (Ord a, Int b) => [a] -> a -> b -> b -> Maybe b
...
0
votes
3answers
108 views
Given an 2D array which is row and column wise sorted. What is the efficient way to search for an element?
For example, given a 2D array (a matrix)
{{1, 2, 3, 4},
{5, 6, 7, 8},
{9, 10, 11, 12}}
What are the solutions to find a number? say 6.
Here's the code I tried using Binary search method -
(code ...
1
vote
1answer
2k views
Implemenatation of Binary search Tree
Written a code to implement BST.
I would like a code review and any suggestions to make it better?
#include<iostream.h>
#include<conio.h>
#include<stack>
#include<queue>
...
0
votes
3answers
241 views
Optimizing function that searches for binary patterns [duplicate]
Possible Duplicate:
Optimizing function that searches for binary patterns
I have two functions that calculate whether or not a given coordinate (x, y) is a diagonal or anti-diagonal of ...
3
votes
2answers
175 views
Improving the efficiency and design of my number guessing game
I have just written a solution to the following problem:
we all know the classic "guessing game" with higher or lower prompts. lets do a role reversal; you create a program that will guess ...
1
vote
2answers
6k views
Deleting a node from Binary Search Tree
I have read about it at few places and tried to write my own version, would like to get it reviewed.
class Node {
private int value;
private Node left;
private Node right
// ...
0
votes
0answers
2k views
InOder successor and predecessor in Binary Search Tree
Do they look correct? I implemented them and was looking to review them
Node predecessor(Node node) {
if ((node.left == null) && (node.right==null)) {
return node;
}
if ...
5
votes
1answer
623 views
Implementations of prefix lookup tables in Python
I've got a fairly performance sensitive need for fast prefix lookup, and I've built two different implementations trying to optimize for my use case. The first is built off a Trie implementation, and ...