algorithm

C# Create an Auth Token from Guid combined with 40Char Hex string (UUID)

I am writing an asp.net MVC app that drives an IPhone application. I want the Iphone to send me its UUID looks like this: 2b6f0cc904d137be2e1730235f5664094b831186 On the server I want to generate a Guid: 466853EB-157D-4795-B4D4-32658D85A0E0 On both the Iphone and the Server I need a simple aglorithm to combine these 2 values ...

algorithm to match prefix and name to a list of names

I have a std::vector<std::string> of all the files in a directory: // fileList folder/file1 folder/file2 file3 file4.ext and a std::set<std::string> of filenames and the same for all used folder prefixes: // set1 file2 file4.ext // set2 folder I need to generate the full (relative) paths to the ALL files in set1, but see no way of...

Algorithm to produce rounded edges and corners in a 3D mesh

Starting with a 3D mesh, how would you give a rounded appearance to the edges and corners between the polygons of that mesh? Without wishing to discourage other approaches, here's how I'm currently approaching the problem: Given the mesh for a regular polyhedron, I can give the mesh's edges a rounded appearance by scaling each polygo...

c++ filling matrix boost

hi i've looked into the vector duplicate of this but couldn't find answer ublas::matrix<int> input; fill(input.begin1(), input.end1(), in_val); fill(input.begin2(), input.end2(), in_val); but it gives me [2,3] {(3,3,3) (3,0,0)} as you can guess i just want to fill all of it with init_val=3 , Thanks. ...

Which algorithm will be required to do this?

I have data of this form: for x=1, y is one of {1,4,6,7,9,18,16,19} for x=2, y is one of {1,5,7,4} for x=3, y is one of {2,6,4,8,2} .... for x=100, y is one of {2,7,89,4,5} Only one of the values in each set is the correct value, the rest is random noise. I know that the correct values describe a sinusoid function whose parameters a...

String Formatting algorithms suggestion

I have following problem: Input String 1 : "A[SPACE]B[SPACE]C[SPACE][SPACE]D[SPACE][SPACE]E" Input String 2 : "1-" OR "1,2" OR "3-" If Input String 2 is 1- then I am supposed to return string from first word If the input string is 3- then i am supposed to return string from 3rd word, If the input string is 1,2 then I am supposed to re...

O(1) Make, Find, Union in Disjoint Sets Data Structure

Today, I had discussion with someone about Kruskal Minimum Spanning Tree algorithm because of page 13 of this slide. The author of the presentation said that if we implement disjoint sets using (doubly) linked list, the performance for Make and Find will be O(1) and O(1) respectively. The time for operation Union(u,v) is min(nu,nv), wh...

is CLR (1st ed.) still relevant?

I just noticed that I have a very old copy of Intro to Algorithms (1st ed.) in my bookshelf that I haven't opened yet. Seeing that now, it's already in the 3rd edition, I would like to know if it's still relevant or would it be best if I get myself the latest 3rd edition instead for learning algorithms. I've been really wanting to beco...

Angle between 3 points?

Given points ABC, how could I find angle ABC? I'm making a feehand tool for a vector drawing application and to minimize the number of points it generates, I wont add a points unless the angle of the mouse position and the last 2 points is greater than a certain threshold. Thanks what I had: int CGlEngineFunctions::GetAngleABC( POINTFL...

Merge elements in IEnumarable according to a conditon

Hello Everyone, I was looking for some fast and efficient method do merge items in array. This is my scenario. The collection is sorted by From. Adjacent element not necessarily differ by 1, that is there can be gaps between the last To and the next From, but they never overlap. var list = new List<Range>(); list.Add(new Range() { Fro...

How to rotate a matrix 90 degrees without using any extra space?

By saying 90 degrees i mean to say if: A = {1,2,3, 4,5,6, 7,8,9} then after 90 degree rotation A becomes: A = {7,4,1, 8,5,2, 9,6,3} ...

fastest way to find a given number 'n' can be absolutely expressed as 2^m

Possible Duplicate: How to check if a number is a power of 2 fastest way to find a given number 'n' can be expressed as 2^m ex: 16= 2^4 naive solution: divide given number by 2 until the remainder becomes 0 (if successful) or less than two (if not successful) Can someone tell me whats the other fastest way to compute this ?...

How do the newer database models achieve better scalability and performance as compared to a traditional RDBMS implementation?

We have BigTable from Google, Hadoop, actively contributed by Yahoo, Dynamo from Amazon all aiming towards one common goal - making data management as scalable as possible. By scalability what I understand is that the cost of the usage should not go up drastically when the size of data increases. RDBMS's are slow when the amount of...

Algorithm for Max and Min diagonal of a convex polygon?

Is there a way better than a brute force comparison to get the max and min length diagonals of a polygon? To be more specific, I would like to find the ratio, so I can sort polygon on their "skinniness." The polygons aren't too large (usually 4-8 faces per polygon), but there's a lot of them. I thought I'd just check with SO to see if ...

How do URL shortener calculate the URL key? How do they work?

How do URL shortener's like bit.ly calculate a random key for each link? What algorithm would I need to know to create my own? ...

Recognizing edges based on points and normals

Hi guys, I have a bit of a problem categorizing points based on relative normals. What I would like to do is use the information I got below to fit a simplified polygon to the points, with a bias towards 90 degree angles to an extent. I have the rough (although not very accurate) normal lines for each point, but I'm not sure how to sepa...

Google crawling indexing algorithms

I am looking for some documents on how Google crawl and index content. I read many "light" papers and articles on what you need to do to improve your ranking and make sure your content is properly indexed but I am looking for some more advanced technical documents on how Google crawl and index content. The things I would like to know mo...

Finding the sum of the digits

I've have a 5 digit integer say, int num = 23456 how to find the sum of the digits.??? ...

Easy interview question got harder: given numbers 1..100, find the missing number(s)

I had an interesting job interview experience a while back. The question started really easy: Q1: We have a bag containing numbers 1, 2, 3, …, 100. Each number appears exactly once, so there are 100 numbers. Now one number is randomly picked out of the bag. Find the missing number. I've heard this interview question before, of cour...

which algorithms i need to learn to write crossword weaver ?

i like to learn a bit about algorithms especially one that can help me to build crossword weaver (simple one ) which algorithms should i learn ? ...