# Tag Info

4

Fortunately, there is a much simpler approach than your multi-threading alternative: implement your backtracking using queues or stacks, instead of recursivity. In this case, when your top state is a solution, you can return it. And you can resume backtracking to find the next solution by processing the next state in the queue/on the stack. This ...

3

Create one data structure that creates all sums of two fourth powers in ascending order, and another one that creates all positive differences of two fourth powers in ascending order. Then compare the numbers from both lists in ascending order. That way you have only O (n^2) numbers to check instead of O (n^3). Basically, search for a^4 + b^4 = c^4 - d^4. ...

3

I am not sure, how exactly you compute 4th power root, but this operation is very expensive. Likewise computing 4th power is costly. Using a database to precompute 4th powers up to a million might save you a lot of resources. Likewise, you can start with a perfect power and try subtraction rather than addition. This way you will skip 100^4+1^4+2^4 cases that ...

2

A dictionary where the key is the word encountered, and the value is a count of the number of times that word is encountered. I think your question has some hidden problem you did not explain. This is trivial.

2

From the comments, it appears that you are dealing with 1 000 points. The usual way to compute a distance between two points, p1 and p2, is: sqrt(pow(p1.x - p2.x, 2), pow(p1.y - p2.y, 2)) I attempted to measure the time it takes to do the operation in C# on a 2.10 GHz CPU (no parallelization, so the number of cores doesn't matter), and failed. With 10 ...

2

This is called sharding in MongoDB and partitioning in SQL Server. If the website actually uses “huge amounts of data”, sharding/partitioning is already implemented. You may probably want to rethink what data you actually need to retrieve, how is it used and how do you store it. If you do auto-completion on product names, you probably don't need to retrieve ...

2

Sorry I didn't read your question correctly at first (and have deleted my comment) //How about this from G = {g[0],g[1],g[2],....} create the set G[0] = { {g[0]}, {g[1]}, {g[2]},...} for each w_i in W find the element c in G[i] such that c contains a point p where p originally came from G, and p is closest to w_i //we want to group w_i along ...

2

This is a very broad topic. Unfortunately there's no general answer, due to the complex matter of patentability. And in view of the existing practice of patent trolling, there is always be some legal risk to be sued in countries in which software patents are accepted. As a first intro, you may be interested in this WIPO article, and especially TIP3, about ...

2

I'd say it's a 1D array, given that a stone and its variant make a single item. Is it a wrong assumption? Your algorithm should be correct, however it is truly a brute-force solution. My simple suggestion: sort these items by the amount of people, who have them in their "favourites". Assign the items to people in this order, expanding a tree bounded by ...

2

Modular arithmetic is the key. First of all, take the total and add all its bytes together. If any carries occur, add those into the total as well (for instance, F0+F6=E7). Continue until you have a single-byte value. The process works just as well if you start by adding 32-bit words to 32-bit words until you have a 32-bit result and then the 16-bit "top ...

2

From the documentation page you linked: Parameters since_id Returns results with an ID greater than (that is, more recent than) the specified ID. There are limits to the number of Tweets which can be accessed through the API. If the limit of Tweets has occured since the since_id, the since_id will be forced to the oldest ID available. Store ...

1

Implementation isn't complicated using recursion. Below is an example of how to solve the satisfiability problem in C#. This is just trying to satisfy each customer with one stone. There might be leftover available stones that a buyer might want which can be added to the bought lists to make the buyers more than satisfied. enum Stone { DiamondRound, ...

1

Backtracking is a good approach. If your implementation gets to complicated you should read some example implementations of backtracking. Remark: Backtracking is not 'trying every possible combination' because you do not try any combination, where already after a few assignments there could no longer be a valid over all assignment. See Early stopping ...

1

Keep segments in sorted order (list, binary tree, whatever...) When adding a new segment, search list, binary tree, whatever to see if it either end of the new segment overlaps an existing segment. If it does, remove/split into new set of segments according to your combining rule (in your example, averaging the overlapping parts). I don't think there is a ...

1

Why not read Frye's article? Here is a digest. You do need modular arithmetic to sieve candidates. Mod 5 works like charm (200 times reduction of the search space). You need to split it in A^4+B^4 and D^4-C^4. The program itself is written in Lisp. The implementation is reasonably straightforward, while the underlying math is neat. First He sieves out ...

1

I don't have a practical comparison between Pearson hashing and the other common suggestions, but I can highlight some assumptions you're making that aren't necessarily true and which might explain why it isn't as popular as you seem to expect: You state that having good distribution of small keys throughout the entire range is just as important as good ...

1

Since most hash algorithms (at least cryptographic ones like the SHA family) are designed to prevent what you're trying to do, you won't have an easy time of it. Some older hash functions like MD5 do have some vulnerabilities, though.

1

If the equation cannot be solved analytically, you need to use numerical algorithm. To make it simple rewrite the equation into form of X + 2 - Y = 0. Then, it becomes a problem of finding a root of equation using numerical method.

1

You could be using a semi-co-routine, or generator. They do not exist in all languages and do not always directly allow recursion. But the capability of doing so and availability of semicoroutines don't depend on availability of threads (granted, they're much easier to implement with threads or fibers, so they're probably more readily available on some ...

1

Matrix decomposition is definitely the way to go here. Which decomposition you use will be determined by the structure of the systems you are are trying to solve: solving using Cholesky decomposition requires a square, symmetric, positive definite, matrix. You can solve a general square matrix using LU or QR. LU is typically used because it usually takes ...

1

If your scene is static (i.e., your triangles don't move, so you can amortize building your acceleration datastructure across all your lines), then I believe that a highly optimized kd-tree is still state of the art for this purpose. Because they have finite extent, your triangles may overlap more than one branch of the kd-tree tree; however, that will be ...

Only top voted, non community-wiki answers of a minimum length are eligible