Hi all,
i'm supposed to write code which when given a text file (source code) as input will output which programming language is it. This is the most basic definition of the problem. More constraints follow:
I must write this in C++.
A wide variety of languages should be recognized - html, php, perl, ruby, C, C++, Java, C#...
Amount o...
lets say I've a list of 10 strings (lets just call it "str1", "str2", ... "str10" etc). I want to be able to generate all pairs from this
("str1", "str2")
("str1", "str3")
.
.
.
etc upto ("str9", "str10"). That is easy, with two loops. How to do the same thing with a million strings? Is there anyway to put it in a table, and run a q...
Hey All,
I'm writing some C where I'm going to need to store a very large graph as an adjacency matrix. I was going to hack up a quick graph implementation, but wanted to ask first if there are any good graph libraries for C (not c++) that people like.
I'm going to import the graph in some standard format (probably GML, but thats not a...
I ran into special case where I need to produce ultra symmetrical line or ray in 2D grid in order from (x0, y0) through (x1, y1) like this:
void drawSymmetricalLine(int x0, int y0, int x1, int y1)
{
// loop and handle each (x, y)...
}
The actual problem lies in points where popular line drawing algorithms does NOT draw both coordi...
I have a cyclic directed graph. Starting at the leaves, I wish to propagate data attached to each node downstream to all nodes that are reachable from that node. In particular, I need to keep pushing data around any cycles that are reached until the cycles stabilise.
I'm completely sure that this is a stock graph traversal problem. Howe...
What is the best algorithm for closest word.
Possible word dictionary is given and first characters in the input word can be wrong.
...
hi... am looking for an efficient algorithm to synchronize two arrays..
Lets say a1 and a2 are two arrays given as input...
a1 - C , C++ , Java , C# , Perl
a2 - C++ , Python , Java , Cw , Haskel
output 2 arrays:
Output A1 : C , C++ , Java
Output A2 : Cw , Haskell , Python
Output A1 :
1) items common to both arrays
2) items only i...
Assume I have a matrix MxN, filled with values between 0 and 5. I now want to determine the largest connected tree in that matrix, where the values of the matrix are considered to be the nodes. A pair of nodes is said to be connected if it's nodes are adjacent to each other either horizontally or vertically, and if the value of both node...
I have to develop a fast heuristic-like algorithm for a hard combinatorial problem. Therefore I think, it would be the best to learn a more expressive language than C++ first for tackling the problem, because I think a lot of different algorithm attempts are needed to solve my assignment.
Some personal views about some languages which a...
Given two orthogonal unit vectors, A and B, and two different orthogonal unit vectors C and D, I need the 3x3 direction cosine matrix or a quaternion which will rotate A to align with C AND will rotate B to align with D.
The vectors are all 3-vectors (x, y, z).
I have a brute force algorithm, but I am almost certain there is a much sim...
My maths in this area is a bit shaky. Does anybody know how I can calculate a power such as 10^2.2 using no maths functions other than */-+ and a for loop? I don't have access to a maths library (and can't import/include it), but need to calculate these things. Hmm.. maybe I should just look how the math library does it.
...
The Towers of Hanoi problem is a classic problem for recursion. You are given 3 pegs with disks on one of them, and you must move all the disks from one peg to another, by following the given rules. You must also do this with the minimum number of moves.
Here's a recursive algorithm that solves the problem:
void Hanoi3(int nDisks, char...
This is not about security. It is also not to make it hard to break. I'm looking for a simple algorithm to change a string (a url) in a way it does not resemble the original. The encryption will be done with javascript. Then I want to feed the encrypted string to a PHP function to change it back to the original. Both ends could share a s...
I have a 12-by-50 array that needs rebinning. The array represents a bivariate probability distribution, p(a,b), where a and b are non-Cartesian coordinates. However, I want to rebin it so that I have a distribution in Cartesian coordinates, p(x,y).
a and b are (mildly) nonlinearly related to x and y, however I make the simplifying ass...
Possible Duplicates:
Program/algorithm to find the time complexity of any given program.
Programmatically obtaining Big-O efficiency of code
Hi, i am eager to develop a function(say computeComplexity()) which can determine the time complexity and space complexity of any algorithm(say bubbleSort()).
Usage of computeComplexit...
I have a large map of String->Integer and I want to find the highest 5 values in the map. My current approach involves translating the map into an array list of pair(key, value) object and then sorting using Collections.sort() before taking the first 5. It is possible for a key to have its value updated during the course of operation.
I...
It's a pretty common algorithm in command line parsing. Given a set of predefined long option names -- compute the shortest prefix that uniquely identifies one of these options. So for instance, for the following options:
-help
-hostname
-portnumber
-name
-polymorphic
This would be the output:
-he
-ho
-por
-n
-pol
I'm thinking tw...
Hi,
I just got this question on a SE position interview, and I'm not quite sure how to answer it, other than brute force:
Given a natural number N, find two numbers, A and P, such that:
N = A + (A+1) + (A+2) + ... + (A+P-1)
P should be the maximum possible.
Ex: For N=14, A = 2 and P = 4
N = 2 + (2+1) + (2+2) + (4+2-1)
N = 2 + 3 ...
I would like to bin vectors in n-dimensional space. This can be done by pixelating the surface of an n-dimensional hypersphere.
Does anyone know any good algorithms for pixelating a hypersphere in C? I would like constant bin sizes. My space consists of only positive integers.
...
It's easy enough to convert a 2-dimensional array to a single-dimensional array but how can I convert a multi-dimensional array of more than 2 dimensions to a one-dimensional array? For example, let's assume I have int [5][5][5] x and int [125] y and I want to place the value at x[3][4][2] in its right place in y?
Hope that makes sens...