I have two arrays, say A and B with |A|=8 and |B|=4. I want to calculate the set difference A-B. How do I proceed? Please note that there are no repeated elements in either of the sets.
Edit: Thank you so much everybody for a myriad of elegant solutions. Since I am in prototyping stage of my project, for now I implemented the simplest s...
hi there!
i want to create a software for planning routes of busses (and their optimal loading) for disabled-kids-transportation.
these busses have following specifications:
m seats (maximum 7 - as there is a driver and an assistance)
o "seats" for wheel-chairs (maximum 4)
fixed amount of maximum load (in austria: 9 or 20 persons; 9 ...
Hi All,
This question is similar to Question i had asked before.
Suppose a library.
The library has many of Books(say B(1 to n)). (n =number of Books)
Each book can have many Chapters (say C(1 to k)) . (k= number of Chapters)
Every Chapter can have number of Lessons (say L(1 to j)) .. (j = number of Lessons)
Every Lessons c...
This is a question that's been lingering in my mind for some time ...
Suppose I have a list of items and an equivalence relation on them, and comparing two items takes constant time.
I want to return a partition of the items, e.g. a list of linked lists, each containing all equivalent items.
One way of doing this is to extend the equiv...
Is it possible to read the contents of a .ZIP file without fully downloading it?
I'm building a crawler and I'd rather not have to download every zip file just to index their contents.
Thanks;
...
I am searching for a table recognition library which can operate on plain text.
Ideally the library is not a dirty hack of regular expression, but something inference-based.
All I can find are papers but no implementations of the concepts described. I am willing to implement such a concept, but I can not believe there is nothing out the...
please ignore this post, I misread algorithm, so the question is not relevant.
However, I cannot close post anymore.
Please vote to close
I have been using certain algorithm from numerical recipes, which converges to zero via underflow:
// all types are the same floating type
sum = 0
for (i in 0,N)
sum += abs(V[i]);
my question, h...
I'm building a website. It has groups that users can join.
The difference between this and "normal" groups is that membership is
temporary - when a user joins a group, he decides the length of membership: 5 days, a
week, 2 weeks, etc (choices are pre-defined). Or potentially all
memberships could be set to be of the same length - say a...
Hello:
I am working on the design of a database which will potentially hold millions of records. Each record will have only a few pieces of data (say, about fifteen fifty-character strings).
The different records belong to the same class of object, but from a different "source"; a namespace would capture this relationship. For instance...
I'm currently preparing for an interview, and it reminded me of a question I was once asked in a previous interview that went something like this:
"You have been asked to design some software to continuously display the top 10 search terms on Google. You are given access to a feed that provides an endless real-time stream of search term...
I'm looking for suggestions for an efficient algorithm for finding all matches in a large body of text. Terms to search for will be contained in a list and can have 1000+ possibilities. The search terms may be 1 or more words.
Obviously I could make multiple passes through the text comparing against each search term. Not too efficient.
...
There's an undirected graph with weights on edges (weights are non-negative integers and their sum isn't big, most are 0). I need to divide it into some number of subgraphs (let's say graph of 20 nodes to 4 subgraphs of 5 nodes each) in a way that minimizes sum of weights of edges between different subgraphs.
This sounds vaguely like th...
I need to come up with a solution for complicated file transfer. I can do this, but I want to know if anybody knows of an open source solution that already does 90% of what I want to do.
The requirements are very odd. Don't try to understand them, they are a hellish mixture of politics, territory, and bureaucracy.
I control two serve...
From the question "Is partitioning easier than sorting?":
Suppose I have a list of items and an
equivalence relation on them, and
comparing two items takes constant
time. I want to return a partition of
the items, e.g. a list of linked
lists, each containing all equivalent
items.
One way of doing this is to extend th...
Hi,
The problem looks like this,
You have to draw N px width line as a M uniform dashes.
If for example N=13 and M=5 you our dash will have 2 px width and we will have 3 px error.
We can do better, we can draw dashes with following widths: 3, 3, 3, 2, 2 .
But we can do even better the dashes can have following widths: 3, 2, 3, 2, 3 ...
I have an array of bytes (any length), and I want to encode this array into string using my own base encoder. In .NET is standard Base64 encoder, but what if I want to encode the array in Base62, Base53 or Base13?
Is it even possible to create such universal base encoder?
I know I could do it the simple way, that is, for each byte rese...
Is there a good algorithm for generating colors for use in graphs such as line / pie / bar charts? Virtually all graphs have a built-in list of colors that they automatically assign to elements added to it. But sometimes you need to manually assign the colors yourself, and in that case you'll want to avoid manually inserting colors yours...
Lets say I have a database filled with people with the following data elements:
PersonID (meaningless surrogate autonumber)
FirstName
MiddleInitial
LastName
NameSuffix
DateOfBirth
AlternateID (like an SSN, Militarty ID, etc)
I get lots of data feeds in from all kinds of formats with every reasonable variation on these pieces of infor...
This problem actually deals with roll-overs, I'll just generalized below as such:
I have a 2D view, and I have a number of rectangles within an area on the screen. How do I spread out those boxes such that they don't overlap each other, but only adjust them with minimal moving?
The rectangles' positions are dynamic and dependent on us...
I have few Cartesian points of the form : (x,y)
where x and y both are non-negative integers.
For e.g.
(0,0) , (1,1), (0,1)
I need an algorithm to arrange the above points
in such a way that going from one point to other
changes either x or y by 1.
In other words, I would like to avoid
diagonal movement.
So, the above mentione...