In mathematics and computer science, an algorithm is an effective method expressed as a finite list of well-defined instructions for calculating a function. Algorithms are used for calculation, data processing, and automated reasoning.

learn more… | top users | synonyms (1)

1
vote
0answers
29 views

Is there a better algorithm to uniformly distribute values from one source to X destinations?

Is there a better algorithm to uniformly distribute values from one source to X destinations? I have some source value. I need to know how much of that value I need to distribute among other values ...
0
votes
0answers
126 views
+100

Fast fixed-size (256 bit) integer modulo/division

What is the fastest way to divide two 256-bit integers? They are represented as an array of 26-bit words, each stored in 32-bit integers. I have access to a 64-bit type if that's useful. It seems ...
2
votes
1answer
139 views

Finding the closest n points to any arbitrary point in two dimensions (r-tree, quadtree, spatial index)

I have a distribution of two dimensional point objects. How is it possible to find the nearest N number of points to any given point without iterating over the entire collection of points (and only ...
-1
votes
1answer
61 views

Intersection of two arrays [on hold]

While solving problem abcdef on spoj i came across this code for intersection of two sorted arrays Here is the link to problem http://www.spoj.com/problems/ABCDEF/ The code sort(s1.begin(), ...
1
vote
1answer
99 views

How can I learn algorithms? [on hold]

I just took a coding challenge on a popular coding challenge site which gives you a problem and a fixed amount of time to solve it. I've been writing software for around 10 years, good software for ...
2
votes
2answers
82 views

Incorporating functions into a Shunting-Yard algorithm implementation

tl;dr What would be a simple way of incorporating functions into a Shunting-Yard algorithm implementation? If only expressions like function(arg1, arg2, arg3) were allowed (where function is some ...
14
votes
5answers
431 views

Algorithm for calculating a bullet path to a target with max. 2 ricochets

Sorry for the poor title but I didn't have a better way to phrase it... So there's this amazing game by Nintendo (yes!) on Wii called WiiPlay. There're 9 minigames in it, and my favorite one is ...
0
votes
1answer
84 views

Split multiple overlapping intervals to non overlapping intervals

currently I try to build an algorithm to split an array of overlapping intervals to a new array with non overlapping intervals. For example: Array of overlapping intervals: [ {0,7}, {8,12}, ...
1
vote
1answer
131 views

Non-fixed-size Fenwick Tree implementation

I'm planning to implement a non-fixed-size Fenwick tree. That is, a Fenwick tree that allows interleaving range queries with adding/removing elements. All implementations and samples I've seen so far ...
19
votes
4answers
3k views

When speaking, how can I say that the time complexity order of an algorithm is O(N log N)?

What term can I use to describe something with O(N log N) complexity? For example: O(1): Constant O(log N): Logarithmic O(N): Linear O(N log N): ?????? O(N2): Quadratic O(N3): Cubic
0
votes
0answers
21 views

What is prerequisite for Algorithm and Data Structure Analysis and Designing [on hold]

I want to learn Programming, So I want to start this learning program with studying of the Introduction to algorithms book. I'm familiar with C, C++ and ASM Language a little bit, but I can't write ...
-3
votes
0answers
96 views

Can My Algorithm be Patented [on hold]

I developed an algorithm that runs about 1000 times faster than the standard version found in other platforms. I did this while I was doing some work for my company. Is this algorithm patentable? If ...
6
votes
2answers
580 views

Why would I care about the asymptotic growth of the lower bound of the worst case time/space?

In mathematics, there are notations for asymptotic lower bounds, upper bounds, and tight (within-a-constant-factor) bounds. When describing the growth of functions in general, it makes sense that all ...
3
votes
1answer
294 views

Efficient algorithm for Virtual Machine(VM) Consolidation in Cloud

PROBLEM: We have N physical machines(PMs) each with ram Ri, cpu Ci and a set of currently scheduled VMs each with ram requirement ri and ci respectively Moving(Migrating) any VM from one PM to ...
2
votes
2answers
95 views

Algorithm to go from infix notation to a tree

I've been trying to figure out an algorithm to go from an infix equation to a syntax tree, like so: (1+3)*4+5 + * 5 + 4 1 3 However, I don't just want it to handle operators, I ...
9
votes
3answers
2k views

My algorithm that extracts the largest box that can be made from smaller boxes, is too slow

Imagine a cube based world (such as Minecraft, Trove, or Cube World) where everything is made up of identically sized cubes and all the cubes are of the same kind. The goal is to represent the world ...
0
votes
0answers
25 views

Why do drawing applications use handles to connect lines to shapes? [migrated]

Most drawing programs that I know of (eg. Visio) give shapes handles in order to connect two shapes with a line. These handles allow lines to be "locked on" to the shape so if you move the shape, the ...
4
votes
2answers
139 views

Merge directed acyclic graphs minimizing number of nodes

I have some DAGs (directed acylic graphs) and I want to merge them in order to minimize the number of nodes (we could say that every node has a cost, while edges are free). These four different DAGs ...
2
votes
3answers
2k views

Is Pre-Order traversal same as Depth First Search?

It seems to me like pre-order traversal and DFS are same as in both the cases we traverse from root till the left branch and back to root and then to the right branch recursively. Could any please ...
3
votes
4answers
4k views

TEA algorithm constant 0x9e3779b9 said to be derived from golden ratio, but the golden number is 1.618?

I'm trying to understand a constant 0x9e3779b9. What kind of data is this? It's not binary, not decimal, what is this? It's a constant used on the TEA algorithm. It says it's derived from the golden ...
-4
votes
0answers
22 views

My code compiles, executes, but crashes for certain inputs [migrated]

I am trying to get the length of longest common subsequence for two strings. It works for most of the inputs but it crashes for the input specified. The code is as follows: #include <cmath> ...
0
votes
0answers
49 views

Calculating audio delay to eliminate echo in VoIP

In this issue, the microphone at point A records audio, compresses it, and sends it to the server at point B somewhere "in the cloud." The point B server then figures out what rooms the recorded ...
2
votes
1answer
569 views

What is O(…) and how do I calculate it?

I've seen some questions here and on SO talking about the most efficient way to find or sort this or that. The questions usually talk about the efficiency of a certain algorithms in terms of O(...). ...
0
votes
1answer
91 views

Bad idea to use the same test cases for multiple parts of a contiguous algorithm?

I'm working on an algorithm that's split up into multiple parts, each of which performs different tasks but is more or less separate from the others, by which I mean the only interaction between the ...
2
votes
3answers
7k views

Why does a proportional controller have a steady state error?

I've read about feedback loops, how much this steady state error is for a given gain and what to do to remove this steady state error (add integral and/or derivative gains to the controller), but I ...
1
vote
1answer
343 views

Assembly vs. algorithmic languages (like C, Algol, etc) [duplicate]

Usually, computer science papers describe algorithms in Algol-like pseudolanguage, similar to Pascal or even C/C++. But Donald Knuth uses his own assembly language (MMIX). Are there any good known ...
1
vote
2answers
79 views

Multi-pattern matching

I have a given byte array in C and I need to match it against several byte arrays and return true if there is any match. I can make various memcmp's but I feel that it is very inefficient. Do you ...
1
vote
1answer
150 views

Is the time complexity of a while loop with three pointers different than 3 nested for loops?

This program (written in ruby) finds the largest 3 numbers in an array (without sorting the array). It has a while loop with three pointers. My fist instinct, since there is only one loop is to say ...
-1
votes
2answers
179 views

How they design this algorithm? [closed]

I started taking the lessons from Codility. In the PDF about time complexity, at the end, the put an simple example: Problem: You are given an integer n. Count the total of 1 + 2 + . . . + n. The ...
2
votes
2answers
3k views

What is the time complexity of the algorithm to check if a number is prime?

What is the time complexity of the algorithm to check if a number is prime? This is the algorithm : bool isPrime(int number){ if(number < 2) return false; if(number == 2) return true; if(number ...
3
votes
2answers
165 views

Obstacle bypass in 2d environment

For this 2d grid (black square are not penetrable, white square are): I want to find path who permit to move an object to a start point (x:18, y:18) to a end point (x:1, y:1), square by square. ...
2
votes
1answer
61 views

Precedence of function in Shunting-yard algorithm

I am working through the Shunting-yard algorithm, as described by wikipedia. The description of the algorithm when dealing with operators is as follows: If the token is an operator, o1, then: ...
1
vote
0answers
44 views

clustering of strings with variable-length prefixes

I've got bunch of strings with variable-length prefixes (or postfixes - I can always revert them) as follows: 0155555555 523455555555 755555555 ... 87129999999999999 119999999999999 09119999999999999 ...
1
vote
1answer
86 views

How to generate Generate Hash incorporating time stamp so it can be unhashed to get the timestamp when it was generated?

I want to create hash based on random id, That hash has to be valid for only 15 minutes. Is there a way to do that? I'm using this for form submission. If some unknown submitted form or some one ...
18
votes
1answer
2k views

3d Packing algorithm for item's shipping

I've received a task to build a shipping estimative that suggests the best accomodation of goods on as few boxes as possible: There is a finite set of known retangular box sizes There are many ...
2
votes
1answer
53 views

Looking for an Appropriate Search Algorithm

I am currently planning an upcoming project and am looking for an algorithm for searching a database. The search is as follows; There will be some specifically labelled criteria (or fields) and I ...
5
votes
2answers
1k views

Writing recursive functions

I am having a lot of trouble writing recursive functions related to trees. I can't just use google for these functions as they are not general and I won't be able to use google in an exam setting! Is ...
1
vote
2answers
60 views

Advantage of non-deterministic staistical analysis?

I am working with a Java Library used for identifying the language of a given text. It relies on an n-gram analysis of the text to return a set of languages it might be and the "confidence" that it ...
14
votes
4answers
927 views

Are Constant Time and Amortized Constant Time effectively considered equivalent?

I need to write a RandomQueue that allows for appends and random removal in Constant Time ( O(1) ). My first thought was to back it with some kind of Array (I chose an ArrayList), since arrays have ...
7
votes
1answer
213 views

Fast indexing of k-combinations

I'm revisiting an old problem that I was working on some time ago. A typical scenario is "3 bits are set within an 8 bit integer", i.e. 00000111. All unique combinations with 3 set bits can easily ...
3
votes
1answer
120 views

Finding the optimal root

I am trying to solve a quora hackathon challenge question. The question descrpition is as follows : For the purposes of this problem, suppose Quora has N questions, and question i (1≤i≤N) takes ...
1
vote
1answer
65 views

Why use a unique hashkey for form submissions?

I have multiple forms and use AJAX to submit them. I asked my boss if he needed any specific format for the form ID and he told me to generate a unique hash and keep it in session; check it whenever ...
-3
votes
2answers
69 views

Integer Map Algorithm

For my project, I need to map integers so that inputting int X will output int Y where both X and Y are defined during runtime. I've used Dictionary<int,int> in .NET but its memory use is too ...
0
votes
1answer
115 views

How to sort fractions (small numbers)

We have 100 000 fractions: Let's consider following fractions. p/(2^q) such that 0 <= p,q <= 10 As you can see there are <= 10 * 10 different fractions, but we have 100 000 that we have to ...
1
vote
1answer
91 views

Algorithm to cut out and straighten rectangles from image

I am looking to write an algorithm to cut rectangular images and straighten them in a new image. The bigger concept is that I will be scanning a bunch of physical pictures (on a physical scanner). ...
4
votes
4answers
450 views

Why are return values from compare functions in many languages defined loosely?

Many languages define that compare functions should return ANY negative value, zero, or ANY positive value. Is there some reason that it shouldn't be clearly defined as -1 0 and 1? Does a wide range ...
0
votes
1answer
102 views

Measure and locate areas of similar value in an image

I saw this picture online and wanted to see if I could create an algorithm to give ordinary images an effect like this: http://justinlivi.net/wp-content/uploads/2011/01/Living_In_Digital.jpg My idea ...
2
votes
1answer
71 views

Best-matching comparative values using all items in array

I have two arrays of objects (items) in the exact same format. Each item represents a wager, and each array represents one of two outcomes for that wager (ex: Team A vs Team B). Both arrays look ...
2
votes
0answers
33 views

Optimizing trigram look ups with wildcards

I am working on creating a spell-checking service for Android (note: this is a platform- and language-neutral question) for Asturian, a minority Romance language. We're using hunspell as the base but ...
1
vote
2answers
259 views

Algorithm to detect if a word is spelled correctly

I am trying to develop a javascript spellchecker that doesn't use a dictionary, and can correctly, given a single word, detect if a word is spelled correctly or not. Right now, I just have a list of ...