I found this famous dp problem in many places, but I can not figure out how to solve.
You are given a set of n types of
rectangular 3-D boxes, where the i^th
box has height h(i), width w(i) and
depth d(i) (all real numbers). You
want to create a stack of boxes which
is as tall as possible, but you can
only stack a box o...
As many will know, one-way encryption is a handy way to encrypt user passwords in databases. That way, even the administrator of the database cannot know a user's password, but will have to take a password guess, encrypt that with the same algorithm and then compare the result with the encrypted password in the database. This means that ...
Hello,
I'm writing an image binarization algorithm which simply converts each pixel's luminance value (grayscale image) to a black or white. Currently the algorithm for binarizing each pixel is roughly this
if( grayscale[x] < thresholdValue)
{
bitonal[x] = 1;
}
(this is actually a simplification of the ACTUAL algorithm because the bit...
I've seen Introduction to Algorithms by Cormen but I find it difficult to read after reading a lot of Head First books. Is there no book that explains Algorithms in a play way manner?
...
I've got a list of 10000 keywords. What is an efficient search algorithm to provide auto-completion with that list?
...
Suppose I have a series of index numbers that consists of a check digit. If I have a fair enough sample (Say 250 sample index numbers), do I have a way to extract the algorithm that has been used to generate the check digit?
I think there should be a programmatic approach atleast to find a set of possible algorithms.
UPDATE: The lengt...
I have three lists of tuples, each tuple contains (startpos, endpos, value).
What I want to do is merge these into one list of tuples (startpos, endpos, values[]), but following a rule which I find it easier to draw than to write:
//third [---------] [------------]
//second [-------------] ...
Hi all, i need help with this minheap code:
#include < vector>
using namespace std;
class heap {
vector <int> v;
public:
int hSize()
{
return v.size();
}
int rsize()
{
return hSize() - 1;
}
int parent(int i)
{
return ...
Please suggest some algorithm to find the node in a tree whose distance to its farthest node is minimum among all the nodes.
Its is not a graph and it is not weighted.
...
What is the Difference between a Heuristic and an Algorithm?
...
I'm bulk loading data into a django model, and have noticed that the number of objects loaded into memory before doing a commit affects the average time to save each object. I realise this can be due to many different factors, so would rather focus on optimizing this STEPSIZE variable.
What would be a simple algorithm for optimizing th...
I'm writing a piece of java software that has to make the final judgement on the similarity of two documents encoded in UTF-8.
The two documents are very likely to be the same, or slightly different from each other, because they have many features in common like date, location, creator, etc., but their text is what decides if they reall...
I have a list of devices and a bitmask of channels they are on (channels are numbered 0..3). There can be up to 256 devices.
For example:
Device1: 1 0 0 1 (on channels 0, 3)
Device2: 0 1 1 0 (on channels 1, 2)
Device3: 1 1 0 0 (on channels 2, 3)
I need to find a bitmask of channels which will result in the message to be received by a...
I make lot of dealing with RFID cards. As much as there are different readers there are different outputs and coding of same type of cards.
I got frequent request to figure out (if possible) to translate one output to another and that means that I have to stare at these numbers and figure out what transformations are.
Most common transf...
Given a binary tree, I want to find out the largest subtree which is a BST in it.
Naive approach:
I have a naive approach in mind where I visit every node of the tree and pass this node to a isBST function. I will also keep track of the number of nodes in a sub-tree if it is a BST.
Is there a better approach than this ?
...
I'm looking for a way of storing graphs as strings. The strings are to be used as keys in a map, so that two topologically identical graphs will map to the same value in the map. Does anybody know of such an algorithm?
The nodes of the tree are labeled with duplicate labels being allowed.
The program is in java and an implementation in...
The problem is this: There is an array of M binary numbers and each of them is in state '0' or '1'. You can perform several steps in changing the state of the numbers and in each step you are allowed to change the state of exactly N sequential numbers. Given the numbers M, N and the array with the members of course, you are about to calc...
How can the following simple implementation of sum be faster?
private long sum( int [] a, int begin, int end ) {
if( a == null ) {
return 0;
}
long r = 0;
for( int i = begin ; i < end ; i++ ) {
r+= a[i];
}
return r;
}
EDIT
Background is in order.
Reading latest entry on coding horror, I cam...
Why people usually do binary search instead of triple search (divide the
array into three parts each time) or even divide into ten parts each time?
...
Does Reed-Solomon error correction work in an instance where there is a dropped byte (or multiple dropped bytes)? For example, let's say it's a (12,8) Reed Solomon code, so theoretically it should be able to correct 2 errors (or 4 erasures if the position is known). But, what happens if only 11 (or 10) bytes are received and one doesn'...