Hello,
John Carmack has a special function in the Quake III source code which calculates the inverse square root of a float, 4x faster than regular (float)(1.0/sqrt(x)), including a strange 0x5f3759df constant. See the code below. Can someone explain line by line what exactly is going on here and why this works so much faster than the r...
Please, excuse my ignorance about this subject :)
C++0x is introducing unordered_set which is available in boost and many other places. What I understand is that unordered_set is hash table with O(1) lookup complexity. On the other hand, set is nothing but a tree with log(n) lookup complexity. Why on earth would anyone use set instead o...
I'm making a user control, and I manually draw the text string, but I can't seem to keep it centered. I need it to stay centered no matter what the font, or string length.
Thanks
...
Hi All,
I wanted to know how can we get the index of the array if the user entered array matches the input array ?
For example:
Input Array = [1,2,3,4] and user entered Array = [2,3] than I should get output as index where both array matches is 1.
Guidance would be highly appreciated.
...
I have the following problem.
I've got a set of items {a1, a2, a3, ... aN}. Each one of those items can contain another set of items {b1, b2, b3, ... bN}. So the end result looks something like this:
a1
b4
b22
b40
b11
b9
a2
b30
b23
b9
b4
b11
a3
b22
b4
b60
b9
As a result of the execution of the algorithm I ...
Hi All,
Why is it necessary to keep visited flag for iterative post order traversal and not for inorder or pre order iterative traversal and is it possible to do post order traversal without keeping visited flag ?
...
Hi All,
I have two arrays, one is very large (more than million entries) and other array is small (less than 1000 entries), what would be the best approach to find maximum number out of all entries in arrays ?
Thanks.
...
What is Median of Sorted Arrays in O(log n) complexity ?
...
For exmple, i have undefined number of a pairs(key, value). And I want to build sorted list during iterate trough this pairs(it is long operation).
I think to use a BinaryTree as a sorted structure and build list from tree after iterations.
How you think in generally, is this method faster than simple sorting of the list getted from it...
The common mixing of RGB colors is very different from mixing colors for paintings,
it's mixing of light instead mixing of pigments.
For example:
Blue (0,0,255) + Yellow (255,255,0) = Grey (128,128,128)
(It should be Blue + Yellow = Green)
Is there any known algorithm for color mixing that works like mixing real colors?
I've alread...
Lets say I have an array of length n and I want to pick k values from it, evenly, starting from 0. If k divides n, then this would be easy, but if k does not divide n, then I need to vary the value m I increment the array pointer with. How would you do this?
For example, if m=1.5 then I want to pick the following numbers:
var arr = arra...
I have a bunch of points in 3d ( an array that contains objects with x,y,z properties ).
My problem is that there are a lot of unnecessary points as illustrated in the image bellow:
How can I cleanup this path ?
At the moment the first thing that comes to mind is to
create an array for the optimized
path
loop though all the poin...
Background:
I'm working with permutations of the sequence of integers {0, 1, 2 ... , n}.
I have a local search algorithm that transforms a permutation in some systematic way into another permutation. The point of the algorithm is to produce a permutation that minimises a cost function. I'd like to work with a wide range of problems, fro...
If I want to represent a guid as a set of integers how would I handle the conversion? I'm thinking along the lines of getting the byte array representation of the guid and breaking it up into the fewest possible 32 bit integers that can be converted back into the original guid. Code examples preferred...
Also, what will the length of th...
I have a problem: I need space-efficient lookup of file-system data based of file path prefix. Prefix searching of sorted text, in other words. Use a trie, you say, and I thought the same thing. Trouble is, tries are not space-efficient enough, not without other tricks.
I have a fair amount of data:
about 450M in a plain-text Unix-for...
Edit: I should rephrase this, what would be a relatively easy algorithm to code in Java for solving a Rubik's cube. Efficiency is also important but a secondary consideration.
Orig: What is the easiest algorithm to code for solving a Rubik's cube? It could be the least efficient but I am looking for something easy to code right now.
...
Friends,
Here is the situation: An ASP.NET page has following query string parameter.
MyServer.com/ShowSomething.aspx?IDs=1000000012,1000000021,1000000013,1000000022&...
Here IDs parameter will always have numbers separated by something, in this case ",". Currently there are 4 numbers but normally they would be in between 3-7.
Now, I...
We are doing some 32bit * 32bit multiplication using the following algorithm
Let us we want to multiply a (32 bit) with b (32 bit), both signed,
a = ah * 2^16 + al [ah - Higher 16 bits, al - Lower 16 bits]
b = bh * 2^16 + bl [bh - Higher 16 bits, bl - Lower 16 bits]
We are effectively doing
Result = (al * bl) + (((ah * bl) + (al * b...
Terminology question !
In many graphics packages the user can draw a line between two objects (two boxes say) and then when the user moves one of the one boxes subseqently the line moves to keep the (visual) connection in place.
I want to learn more about this functionality might be implemented (really good to find some open source cod...
I have a set of 2D points from which I want to generate a polygon (or collection of polygons) outlining the 'shape' of those points, using the following concept:
For each point in the set, calculate the convex hull of all points within radius R of that point. After doing this for each point, take the union of these convex hulls to produ...