First of all - I checked a lot in this forum and I haven't found something fast enough.
I try to make a function that returns me the prime numbers in a specified range.
For example I did this function (in C#) using the sieve of Eratosthenes. I tried also Atkin's sieve but the Eratosthenes one runs faster (in my implementation):
public s...
As PHP is simpler for me I wished to benchmark algorithms in it for fun, and I chose to do factorials.
The recursive function completely flunked in speed when I got up to 80! compared to the iterative method, and it gradually skyrocketed upwards while iterative had a steady line, actually it is something like this (x = factorial, y = se...
I have tried again to ask the same question, but I ended up asking a different question by not providing essential information about my problem.
I implement a data structure which is a tree. Each node of this tree has an array/vector/(random access structure) with all its children which can be arbitrary many. The insertion/removal of el...
Any decent visualization of a couple different sort algorithms? I'm looking for something I can use in a demo, and willing to write my own (can't be that hard) but would prefer to use someone else's if I can.
NO applets though, the majority I'm finding are applets... Lightweight flash or canvas. I would like the following sorts:
Bubbl...
Given a database of long/lat coordinates representing targets and a series of lat/long representing the bounding coordinates of polygons representing "zones". Using a simple ray casting algorithm is it safe to treat the lat/long as cartesian coordinates for determining if the target is within the zone?
...
Hello,
I'm trying to come up with a way to distort an image similar to the example here:
http://tinypic.com/r/16gn60o/7
The idea is to remove any hard lines in the original image. I would like the original image to be "about the same" not a hard swirl effect you see in some screensavers or anything like that.
Any pointers or idea woul...
Is there any algorithm(s) that can find all the paths, between a source and a sink, in a given connected, undirected, weighted graph / network?
The network consists of multiple source nodes and a single sink node. The path should be free of loops
...
Some student asked this on another site, but got no answers. I had a few stabs at it, but found it pretty tricky.
Doing it with just the switches would require a 9:1 compression ratio, so I guess the trick is very much in the rules you assign to students. Perhaps every student needs a different set of rules?
I've thought about allowin...
Hi everyone. I want to use an asymmetric cryptography algorithm, but i need it have short Key Size(not like RSA which is at least 384).
I need it to be about around 20.
Is it possible ?
...
how do i solve for running time in the towers of Hanoi problem. I get a recurrence realation like t(n) = 2t(n-1) + 1. After drawing the recursion tree i get at every step values like 1+2+4+8... the height of the tree will be lg(n). how do i calculate the sum of the series? when do i stop?
...
Possible Duplicate:
Getting the submatrix with maximum sum?
Given a 2-dimensional array of positive and negative integers, find the sub-rectangle with the largest sum. The sum of a rectangle is the sum of all the elements in that rectangle. In this problem the sub-rectangle with the largest sum is referred to as the maximal su...
What will be the most efficient way to find a cross-link in a binary tree ?
5
/ \
3 7
/ \ / \
2 4 6 8
Now in this tree consider a link between 4 and 5. So how can we find that there is a cross-link from 4 (ie. finding the node from which the cross-link emanates)
(I was asked this question in an in...
I am looking for the solution of following algorithm with minimal time and space complexity.
Given two arrays a and b, find all pairs of elements (a1,b1) such that a1 belongs to Array A and b1 belongs to Array B whose sum a1+b1 = k (any integer).
I was able to come up with O(n log n) approach where we will sort one of the array say...
I need a hash function that takes a few (eg. 2 or 3) unsigned integers as input, and returns a floating point value between -1 and +1.
The collection of these returned values must be evenly distributed. A sequence of outputs from the function must appear to be a random sequence, even if the input numbers are sequential.
Also the faster ...
How to convert HSV color directly to CMYK color?
Bonus points for mentioning JavaScript library that does that.
I've seen only solutions that convert HSV to RGB and then RGB to CMYK.
...
Disclaimer: Homework question. I'm looking for a hint…
Professor F. Lake tells his class that it is asymptotically faster to square an n-bit integer than to multiply two n-bit integers. Should they believe him?
I believe that multiplying two n-bit ints via shift/add is an O(n) operation, but I can't see why squaring an n-bit int would...
Hello
Both can be used to find the shortest path from single source. BFS runs in O(E+V) while Dijkstra's runs in O((V+E)*log(V))
But I've seen Dijkstra used a lot like in routing protocols
...
There are two sets of URL, both contains millions of URLs. Now, How can I get an URL from A that is not in B. What's The best methods?
Note: you can use any technique, use any tools like database, mapreduce, hashcode, etc, . We should consider the memory efficient, time efficient. You have to consider that every set (A and B) have millio...
Does anyone know of a method to convert words like "first", "tenth" and "one hundredth" to their numeric equivalent?
Samples:
"first" -> 1,
"second" -> 2,
"tenth" -> 10,
"hundredth" -> 100
Any algorithm will suffice but I'm writing this in C#.
EDIT
It ain't pretty and only works with one word at a time but it suits my purposes. Mayb...
I'm usually a lot better than this, I promise.
Back story here: At my job, if you are late/absent, you get attendance points. One way to work attendance points off is to work weekend hours. For every 12 weekend hours you work, you get 2 attendance points removed.
For example, if an employee has 26 weekend hours built up, I need to sub...