Hey everyone,
Before I start coding, I want to come up with a good design first. Basically, I have a database table filled with dates, and users who are associated with those dates (the dates are in sql format).
Using PHP I want to, for each user, calculate (count in total) how many weekdays they are associated with, as well as how ma...
Where I can find the display algorithm for multi-parents linking.
I like to draw it on 2-dimension paper without crossing lines.
So it is connecting with Set of parents to set of children where there is many to many relationship.
...
Given two dates, what is the best method to calculate the number of days between those two dates that fall in a leap year.
For example if d1 = 12/1/2007 and d2 = 1/31/2008 then the total number of days between d1 and d2 would be 62 and the number of days that fall in a leap year would be 31.
Another example is if d1 = 12/1/2007 and...
I need to sort some products base on user ratings.
Suppose we have 3 products {a,b,c} and we have user's feed backs about this products.
It's not important which user give us feed back (this question is not about correlative filtering if you are familiar with it - user interests is not the case here)
Each of these below lines are feed...
An aggregate type T is made up of 4 strings: t = c1 c2 c3 c4
Each of c1 c2 c3 c4 can have a number of unique values:
c1 may have a number of unique values c1.1, c1.2, c1.3, ... c1.n, where 'n' can be fairly high, about 30,000.
c2 has far fewer unique values, no more than 5, i.e., n < 5
For c3 and c4, n is unpredictable but generally 1...
This is the problem:
I have n points (p1, p2, p3, .. pn), each of them can connect to any other with a determined cost x.
Each point belongs to one of a set of point-types (for example "A" "B" "C" "D"...).
The input of the method is the path I want to follow, for example "A-B-C-A-D-B".
The output is the shortest path connecting the p...
Ok, so I am working with a PIC microprocessor, in C. It's a 16F, so it can't hold integers larger than 32bits (unsigned int32 is the largest datasize available)
From a reader, I receive a 5 byte ID code. To transmit it, I have to encoded to BCD, digit by digit. I can't sprint it to a string, as it is larger that the data size, and can't...
Does anyone know an algorithm for the following problem:
Given a undirected connected graph find the number of ways in which 2 distinct edges can be cut such that the graph becomes disconnected.
I think a part of the problem (which i know an algorithm for) is calculating the number of ways in which 1 line can be cut so that it becomes ...
Four men have to cross a bridge at night.Any party who crosses, either one or two men, must carry the flashlight with them. The flashlight must be walked back and forth; it cannot be thrown, etc. Each man walks at a different speed. One takes 1 minute to cross, another 2 minutes, another 5, and the last 10 minutes. If two men cross to...
I have a block of text (of arbitrary length) with a particular word highlighted in yellow whenever it appears. I want to show only a 400 word chunk of the text but I want to show the chunk with the most highlighted words.
Does anyone know a good algorithm for this?
I have the character position of each highlighted word, so the algorith...
I would like to know if compression algorithms always generate unique output for two different sets of files.
Say, I have two files A and B, and say I am applying a compression algorithm (for instance like PKZIP - this could be any compression algorithm) for each of these files to get A.zip and B.zip respectively. Is it possible for A.z...
Given a long string L and a shorter string S (the constraint is that L.length must be >= S.length), I want to find the minimum Hamming distance between S and any substring of L with length equal to S.length. Let's call the function for this minHamming(). For example,
minHamming(ABCDEFGHIJ, CDEFGG) == 1.
minHamming(ABCDEFGHIJ, BCDGHI...
Hello,
this evening I tried to solve a wood puzzle so I wondered which is the best way to find a solution to this kind of problem programmaticaly..
The aim is to combine a set of solids (like tetris pieces in three dimensions) together combining a shape in a feasable way that takes care of the fact that pieces can be attached or slided...
hello, i am looking for a sample code implementation on how to invert a 4x4 matrix. i know there is gaussian eleminiation, LU decomposition, etc. but instead of looking at them in detail i am really just looking for the code to do this.
language ideally C++, data is available in array of 16 floats in cloumn-major order.
thank you!
...
The kernel trick maps a non-linear problem into a linear problem.
My questions are:
1. What is the main difference between a linear and a non-linear problem? What is the intuition behind the difference of these two classes of problem? And How does kernel trick helps use the linear classifiers on a non-linear problem?
2. Why is the dot ...
How to add two numbers without using ++ or + or any other arithmetic operator. It was a question asked a long time ago in some campus-interview. Anyways today someone asked a question regarding some bit-manipulations, and in answers a beautiful quide *stanford Bit Twiddling * was referred. I spend some time studying it, and thought that ...
I have a set of double-precision data and I need their list to be always sorted. What is the best algorithm to sort the data as it is being added?
As best I mean least Big-O in data count, Small-O in data count (worst case scenario), and least Small-O in the space needed, in that order if possible.
The set size is really variable, fro...
I remember hearing about the following algorithm some years back, but can't find any reference to it online. It identifies the top k elements (or heavy hitters) in a data stream of n elements using only m counters. This is particularly useful for finding top search terms, network abusers, etc. while using minimal memory.
The algorithm: ...
You are given an array with integers between 1 and 1,000,000. One integer is in the array twice. How can you determine which one? Can you think of a way to do it using little extra memory.
Algo:
Solution 1:
Have a hash table
Iterate through array and store its elements in hash table
As soon as you find an element which...
Can someone hep me find an algorithm for a recursive function func(int k) to return 3^k in only n+1 calls where k is in the range [ 3^n, 3^(n+1) )
For example, the function should return 3^1 or 3^2 in 1 call, 3^3, 3^4, .. 3^8 in 2 calls, 3^9, 3^10 .. in 3 calls and so on.
...