I'm looking for implementations of set reconciliation algorithm. The problem is following: there are two sets with elements identified by some relatively compact value (e.g. UUID or MD5/SHA1/whatever hash) sitting on different machines. These sets differ in relatively few elements and I want to synchronize these sets while transferring m...
I am looking to discuss branch and bound solution for TSP with multiple visits.(that is every city needs to be visited atleast once , instead of just once)
Edit:
Removed the doubt as it was not relevant as pointed by Jitse. Now the question is more clear.
...
I need to generate a large list of random numbers from 600k to 2000k, but the
list can not have duplicates.
My current 'implementation' looks like this:
<?php
header('Content-type: text/plain');
$startTime = microtime(true);
$used = array();
for ($i=0; $i < 600000; ) {
$random = mt_rand();
//if (!in_arr...
I am lookin for a method to have number of 1's in 32 bit number
without using a loop in between.
can any body help me and provide me the code or algorithm
to do so.
Thanks in advance.
...
This question about zip bombs naturally led me to the Wikipedia page on the topic. The article mentions an example of a 45.1 kb zip file that decompresses to 1.3 exabytes.
What are the principles/techniques that would be used to create such a file in the first place? I don't want to actually do this, more interested in a simplified "how...
I have two tables, pages and revisions. Revisions has a foreign key to a page. The contents of a page is the latest entry in the revisions table for that page. The revisions are full copies of the contents, no deltas.
As an experiment, I would like to visualize the revision state of the current revision. If text is new in the current re...
I'm trying to write a merge sorting algorithm in Perl and I've attempted to copy the pseudo code from Wikipedia.
So this is what I have:
sub sort_by_date {
my $self = shift;
my $collection = shift;
print STDERR "\$collection = ";
print STDERR Dumper $collection;
if ( @$collection <= 1 ) {
return $c...
As the title suggests i would like to know whether it is possible to "WRITE A PROGRAM or ALGORITHM" to find the time complexity of any given program taken as input?
Input : any program(P) [in any language or of a particular language]
Output : time complexity of that program(P).
Have there been any prior attempts to write such a progra...
Let's say I have 20 players [names A .. T] in a tournament. The rules of the tournament state that each player plays every other player twice [A vs B, B vs A, A vs C .. etc]. With 20 players, there will be a total of 380 matches.
In each match, there are three possible outcomes - player 1 wins, player 2 wins, or draw. There's a betting ...
I am looking for an algorithm to prune short line segments from the output of an edge detector. As can be seen in the image (and link) below, there are several small edges detected that aren't "long" lines. Ideally I'd like just the 4 sides of the quadrangle to show up after processing, but if there are a couple of stray lines, it won'...
UPDATE:
The final version of my utility looks like this:
StringBuilder b = new StringBuilder();
for(char c : inLetters.toLowerCase().toCharArray())
{
switch(c)
{
case '0': b.append("0"); break;
case '1': b.append("1"); break;
case '2': case 'a': cas...
I am writing a test tool which places a large amount of load on a network service. I would like this tool to start with little load and gradually increase over time. I am sure that there is some triganometry which can do this sort of calculation in one line of code but I am not a math guru (yet). Is there some sort of library (or simple ...
I am programming an algorithm where I have broken up the surface of a sphere into grid points (for simplicity I have the grid lines parallel and perpendicular to the meridians). Given a point A, I would like to be able to efficiently take any grid "square" and determine the point B in the square with the least spherical coordinate distan...
I'm after some ideas for demonstrating the usefulness of Floyd-Warshall visually. So far all I can think of is generating a random graph, allowing the user to select a start/finish and highlight the shortest path. What are some more fun yet simple demonstrations of the usefulness of path-finding?
...
I am implementing a custo crypto library using the Diffie-Hellman protocol (yes, i know about rsa/ssl/and the likes - i am using it specific purposes) and so far it turned out better than i original expected - using GMP, it's very fast.
My question is, besides the obvious key exchange part, if this protocol can be used for digital signa...
How can i generate a unique string from the post title in my C# code ? Similar to the one which appears in the url of this post.
...
Hello,
I am looking for a method to determine if there is a solution to equations such as:
3n1+4n2+5n3=456, where n1,n2,n3 are positive integers.
Or more general: are there zero or positive integers n1,n2,n3... that solves the equation k1n1+k2n2+k3n3...=m where k1,k2,k3... and m are known positive integers.
I don't need to find a solut...
I am having difficulties doing this program. It's transportation method using intuitive approach. you will first create two inputs that will describe how many rows and columns will the user wish to have. and then, after clicking a submit button, a desired number of rows and columns will appear. then the user will input the number of valu...
I have 2 set of unsorted integers: set A and set B. But we don't know how many items are there in setB in advance.
I need to :
while setA and setB are not empty:
pop the smallest no from setA
move an int from setB to setA
What is the most efficient way to do that in Java?
I am thinking
create an ArrayList for setA and Link...
Link to the original problem
It's not a homework question. I just thought that someone might know a real solution to this problem.
I was on a programming contest back in 2004, and there was this problem:
Given n, find sum of digits of n!. n can be from 0 to 10000. Time limit: 1 second. I think there was up to 100 numbers for each t...