I have a 128-bit unsigned integer A and a 64-bit unsigned integer B. What's the fastest way to calculate A % B - that is the (64-bit) remainder from dividing A by B?
I'm looking to do this in either C or assembly language, but I need to target the 32-bit x86 platform. This unfortunately means that I cannot take advantage of compiler sup...
Hi,
Is there a library of data structures and operations for quadratic bezier curves? I need to implement:
bezier to bitmap converting with arbitrary quality
optimizing bezier curves
common operations like subtraction, extraction, rendering etc.
languages: c,c++,.net,python
Algorithms without implementation (pseudocode or etc) could ...
I am porting code from Matlab to Python and am having trouble finding a replacement for the firls( ) routine. It is used for, least-squares linear-phase Finite Impulse Response (FIR) filter design.
I looked at scipy.signal and nothing there looked like it would do the trick. Of course I was able to replace my remez and freqz algoriths...
I am currently developing a little sketching application based on HTML5 Canvas element. There is one particular problem I haven't yet managed to find a proper solution for.
The idea is that the user will be able to manipulate existing stroke data (points) quite freely. This includes pushing point data around (ie. magnet tool) and manipu...
So first of all I have such image (and ofcourse I have all points coordinates in 2d so I can regenerate lines and check where they cross each other)
But hey, I have another Image of same lines (I know thay are same) and new coords of my points like on this image
So... now Having points (coords) on first image, How can I determin ...
Hi, i am designing a Chinese auction website.
Tickets ($5, $10 & $20) are sold either individually, or via packages to receive discounts.
There are various Ticket packages for example:
5-$5 tickets = receive 10% off
5-$10 tickets = receive 10% off
5-$20 tickets = receive 10% off
5-$5 tickets + 5-$10 tickets + 5-$20 tickets = receive 1...
Is there a good algorithm to calculate the cartesian product of three seqs concurrently in Clojure?
I'm working on a small hobby project in Clojure, mainly as a means to learn the language, and its concurrency features. In my project, I need to calculate the cartesian product of three seqs (and do something with the results).
I found t...
Hello,
I'm looking for a data structure that provides indexing for Rectangles. I need the insert algorithm to be as fast as possible since the rectangles will be moving around the screen (think of dragging a rectangle with your mouse to a new position).
I've looked into R-Trees, R+Trees, kD-Trees, Quad-Trees and B-Trees but from my un...
I have a number of rectangles of various widths and heights. I have a larger rectangular platform to put them on. I want to pack them on one side of the platform so they spread in the lengthwise (X) dimension but keep the widthwise (Y) dimension to a minimal. That is to place them like a tetris game. There can be no overlaps but there ca...
1-)For sorted array I have used Binary Search.
We know that the worst case complexity for SEARCH operation in sorted array is O(lg N), if we use Binary Search, where N are the number of items in an array.
What is the worst case complexity for the search operation in the array that includes duplicate values, using binary search??
Will it...
What algorithm would you suggest to identify how much from 0 to 1 (float) two texts are identical?
Note that I don't mean similar (ie, they say the same thing but in a different way), I mean exact same words, but one of the two texts could have extra words or words slightly different or extra new lines and stuff like that.
A good examp...
Hi all,
I've been implementing my own version of a red-black tree, mostly basing my algorithms from Wikipedia (http://en.wikipedia.org/wiki/Red-black_tree). Its fairly concise for the most part, but there's one part that I would like clarification on.
When erasing a node from the tree that has 2 non-leaf (non-NULL) children, it says to...
Hi,
I'm working on a sudoko solver (python). my method is using a game tree and explore possible permutations for each set of digits by DFS Algorithm.
in order to analyzing problem, i want to know what is the count of possible valid and invalid sudoko tables?
-> a 9*9 table that have 9 one, 9 two, ... , 9 nine.
(this isn't exact dupl...
I know the question is not too specific.
All I want is someone to tell me how to convert a normal merge sort into an in-place merge sort (or a merge sort with constant extra space overhead).
All I can find (on the net) is pages saying "it is too complex" or "out of scope of this text".
The only known ways to merge in-place (with...
Hi,
Say I have two 2D vectors, one for an objects current position and one for that objects previous position. How can I work out the direction of travel?
This image might help understand what I'm after:
Thanks
-James
...
I have a lot of cycles ( indicated by numeric values, for example, 1-2-3-4 corresponds to a cycle, with 4 edges, edge 1 is {1:2}, edge 2 is {2:3}, edge 3 is {3,4}, edge 4 is {4,1}, and so on).
A cycle is said to be connected to another cycle if they share one and only one edge.
For example, let's say I have two cycles 1-2-3-4 and 5-6-7...
If you have one billion numbers and one hundred computers, what is the best way to locate the median of the numbers?
one solution which i have is:
split the set equally among the 100 computers - sort them - find medians for each set.
sort the sets on medians. merge two sets at a time starting from the lowest median to highest.
if we h...
Suppose my input is (a,b and c to distinguish between equal keys)
1 6a 8 3 6b 0 6c 4
My counting sort will save as (discarding the a,b and c info!!)
0(1) 1(1) 3(1) 4(1) 6(3) 8(1)
which will give me the result
0 1 3 4 6 6 6 8
So, how is this stable sort?
I am not sure how it is "maintaining the relative order of records with equa...
Can anyone suggest how to solve the Log Pile wooden puzzle using a computer program?
See here to visualise the puzzle: http://www.puzzlethis.co.uk/products/madcow/the_log_pile.htm
The picture only shows some of the pieces. The full set of 10 pieces are configured as follows with 1 representing a peg, -1 representing a hole and 0 repres...
Hi,
I am about to start developing an edge detection system (once I've read through a couple of books, which I'm doing so at good speed), but one thing I am wondering is the speed of an app like Matlabs (which can compile code to C++) vs AFORGE.NET for edge detecton.
Is unmanaged code generally faster?
Thanks
...