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)

2
votes
2answers
470 views

Transform math formula into code (line-line intersection)

I'm having hard times transforming a math formula to code. I can solve it on the paper easily, but it's hard for me to bring it into code form. Is it generally possible to bring a math formula ...
26
votes
8answers
4k views

Is the algorithm more important than the programming language?

During the current (2013) Google Code Jam contest, there was a problem that took C++ and Java people 200+ lines of code as compared to Python people that solved the same problem only using 40 lines of ...
1
vote
1answer
524 views

Puzzle solving: Minimum number of steps to achieve a goal

I have been doing some programming contest problems, and I have noticed that many of them involve something along the lines of "get the minimum number of steps necessary to achieve a certain goal". ...
2
votes
4answers
338 views

Approach to simplifying an algorithm

For completely random reasons*, I wrote some code that calculates and displays the following expression: P=1*(2+2)(3+3+3)(4+4+4+4)..(n+n...… Which is equivalent to (n!)^2 The version I wrote ...
11
votes
7answers
2k views

Generating random math expression

I have this idea running around in my head, to generate and evaluate random mathematical expressions. So, I decided to give it a shot and elaborate an algorithm, before coding it to test it. Example: ...
-1
votes
2answers
415 views

What is the best programming language to do crypto running time measurement? [closed]

I am trying to measure the running time of different crypto algorithm. e.g. how long it takes to encrypt/decrypt a block of plaintext. May I ask if C with OpenSSL is the best PL to do this?
0
votes
1answer
258 views

Creating alien symbols or signs that look natural [closed]

I was reading some Cthulhu Mythos stuff and started to think about those various signs and symbols that are used in the texts. Of course those are made by humans but point is that they look natural to ...
0
votes
2answers
222 views

How can I compute maximal area including only given integer pairs of (x,y) coordinates?

The values ​​of a function of two variables z = f (x, y), where x, y, z take integer values are stored in sql db. Calculate (appoint) the largest surface area of ​​the flat. By 'flat area' we mean an ...
8
votes
1answer
344 views

Does any know of a Algorithm that allows for a figure like this image?

Does anyone know how to create an algorithm capable of making the figure just like in the picture, when given a set of specific points (3D array)
1
vote
2answers
389 views

Can we create a program that writes out its source code?

Can we create a program that print out its source code what if we (or the program itself) compile than the new program would have the same exact functionality what the original program has? So somehow ...
0
votes
4answers
507 views

What does it mean to perform an operation “In Place” for Interpreted Languages?

Programming question: Reverse words in a string (words are separated by one or more spaces). Now do it in-place. What does "in-place" mean in the above context for an interpreted language ...
3
votes
4answers
784 views

How to determine most challenging test-cases to test any algorithm?

While solving any problem, we write algorithms. Some efficient, some not, some work, some fail. But sometimes we end up writing something which is mostly a success when we do a dry test run, perhaps, ...
1
vote
1answer
227 views

finds all possible permutations of a certain numbers of distinct digits

I am stuck on the following problem. I want to find an algorithm that finds all possible permutations of a certain numbers of distinct digits and then put them in a large matrix for instance. For ...
0
votes
2answers
1k views

How to find local maxima in matrices?

I need to develop an algorithm for finding all the local maxima in a two-dimensional array: how to search for local maxima in the the most efficient way? Are there algorithms about it? Moreover, the ...
0
votes
1answer
260 views

Linear probing hashing collision resolution

So I have a quick question about the linear probing method of collision resolution in hash tables. So by definition a linear probing method would look like: while (hashTable[hash] != null) hash = ...
10
votes
1answer
439 views

Functional Reactive/Relational Programming – Is there a difference?

I've been using Reactive Cocoa (by GitHub), a Functional Reactive Programming API for use with the Cocoa libraries for a while now, but have just read "Out of the Tar Pit", the paper that supposedly ...
17
votes
6answers
6k views

What methods are there to avoid a stack overflow in a recursive algorithm?

Question What are the possible ways to solve a stack overflow caused by an recursive algorithm? Example I'm trying to solve Project Euler problem 14 and decided to try it with a recursive ...
1
vote
2answers
423 views

The physical implementation of quantum annealing algorithm

From that question about differences between Quantum annealing and simulated annealing, we found (in comments to answer) that physical implementation of quantum annealing exists (D-Wave quantum ...
4
votes
8answers
882 views

How meaningful is the Big-O time complexity of an algorithm?

Programmers often talk about the time complexity of an algorithm, e.g. O(log n) or O(n^2). Time complexity classifications are made as the input size goes to infinity, but ironically infinite input ...
4
votes
1answer
810 views

What is the difference between Quantum annealing and simulated annealing?

In both algorithms objective functions, that will be executed with non quantum computers, are used. Both algorithms are methods for finding the global minimum of a given objective function. From ...
3
votes
6answers
338 views

Transforming A Physical Algorithm into a Computerized One

I have realized that its possible to create algorithms that operate physically to solve problems much more efficiently than in a computer itself. Consider the following: Finding the shortest path ...
2
votes
2answers
599 views

Ring of numbers where adjacent entries sum up to a prime

Given a number n, find a permutation of the numbers 1...n such that all adjacent entries sum up to primes. If such a permutation does not exist, throw an error. Is there a purely-functional way to do ...
1
vote
1answer
109 views

Permuting a list of numbers by pushing and popping onto a stack

Suppose we have some long stack of numbers. There is another intermediate stack, and a destination stack to be returned in the end. The only two operations allowed is transferring the top of the old ...
32
votes
6answers
2k views

I'd like to write an “ultimate shuffle” algorithm to sort my mp3 collection

I'm looking for pseudocode suggestions for sorting my mp3 files in a way that avoids title and artist repetition. I listen to crooners - Frank Sinatra, Tony Bennett, Ella Fitzgerald etc. singing old ...
8
votes
1answer
288 views

heuristic for searching through non-perfectly sorted data

Given sorted data, the search solution is obvious. Given unsorted data, sensible options are sort then search or just linear search. This question is about what to do if the data is somewhat sorted, ...
14
votes
4answers
2k views

Is this a Proper “Rule” for Identifying the “Big O” Notation of an Algorithm?

I've been learning more about Big O Notation and how to calculate it based on how an algorithm is written. I came across an interesting set of "rules" for calculating an algorithms Big O notation and ...
2
votes
4answers
851 views

Applications of heapsort

Heapsort is a sorting algorithm that has a time complexity of O(nlogn), and performs sorting using O(1) space complexity. However, I know that because it's unstable, it doesn't find many applications ...
8
votes
1answer
633 views

Possible Damerau-Levenshtein improvement?

I recently implemented the Damerau-Levenshtein distance algorithm from the pseudocode on Wikipedia. I couldn't find any explanation of exactly how it works and the pseudocode uses completely ...
-2
votes
2answers
259 views

About Artificial Intelligence [closed]

I am interested in starting a career in artificial intelligence. Can anyone suggest how I could prepare for this? What languages should I study that would be best for this career choice?
6
votes
3answers
1k views

What algorithm should I use to find the shortest path in this graph?

I have a graph with about a billion vertices, each of which is connected to about 100 other vertices at random. I want to find the length of the shortest path between two points. I don't care about ...
-1
votes
1answer
149 views

Best way to clear balances between payers and payees

Say some 20 people go to a shop and everyone buys something. When it comes to paying, 5 of them pay the complete amount of 10,000$ split unequally between them. Since everyone bought different ...
3
votes
3answers
3k views

what is a efficient way to find repeating decimal

I am trying to find a efficient algorithm in Java to find the repeating decimal part of two integers a and b where a/b. eg. 5/7 = 0.714258 714258.... I currently only know of the long division ...
1
vote
1answer
163 views

Course Map Generator

My university lists the rotation of courses each semester/year. Therefore, it is possible to predict when every class will be taught. I am trying to create a JavaScript (language is irrelevant, ...
0
votes
1answer
551 views

Fast lookup hash map implementations

I'm in the process of implementing a programming language on top of LLVM. For my polymorphic system, I'm looking for suggestions for a ultra-fast dictionary. I am not concerned with insert time, as ...
0
votes
3answers
143 views

Search on multiple values

I have a database having around 15 tables.Currently I am working on a report generation page, which is having 16 criteria.The values are distributed among multiple tables.User can select any number of ...
-2
votes
1answer
535 views

using ant colony algorithm to create cross word game [closed]

I have difficulty to learn about ant colony algorithm (ACO), I have read about generating crossword game using (genetic algorithm) GA.I Know both of GA ant ACO usually used for optimization, but my ...
5
votes
5answers
672 views

Why interviewers want Optimal Algorithms

In an interview with a software company they asked me some algorithm design questions. Being strong in mathematics I was able to solve it mathematically, but each time when I propose my algorithm ...
2
votes
4answers
1k views

How do you find the first common element in two arrays

The way I did it was to loop through each at the same time and add the current value to a separate set for each of the lists. Also, check if the current element is already in the other list's set. I ...
0
votes
0answers
116 views

Efficiently compute distance of location to POIs?

I want to write an android application that holds information where (climbing) rocks are located in a wider area. I want to display all rocks nearby my current location (say below 500m) and may be ...
3
votes
2answers
488 views

Programming interview: on sorted arrays, algorithm proof

The following is a programming interview question: Given 3 sorted arrays. Find(x,y,z), (where x is from 1st array, y is from 2nd array, and z is from 3rd array), such that Max(x,y,z) - Min(x,y,z) is ...
3
votes
1answer
341 views

Stereo images rectification and disparity: which algorithms?

I'm trying to figure out what are currently the two most efficent algorithms that permit, starting from a L/R pair of stereo images created using a traditional camera (so affected by some epipolar ...
3
votes
1answer
724 views

A* Algorithm Completeness Proof

The A* Algorithm is the optimal (provided the heuristic function is underestimated), complete & admissible (provided some conditions). I know the proofs of admissibility & optimality. But how ...
5
votes
5answers
712 views

Fastest way to find the closest point

I have a list in Python 2.7 of about 10000 point co-ordinates, like [(168, 245), (59, 52), (61, 250), ... (205, 69), (185, 75)] Is there a faster way to search for all the points in a bounding box, ...
5
votes
5answers
258 views

What sort of questions drive the decision as to whether similar code is separate or common?

I have come across the following problem many times in various guises in my programming career. As a simple example, consider the following: Let's say there is a method (B) that could differ ...
7
votes
3answers
434 views

Longest subsequence without string

Does there exist a dynamic programming algorithm to find the longest subsequence in a string X that does not contain Y as substring? Just that this problem seems so similar to other DP string ...
0
votes
1answer
148 views

LOOP program only need inc and zero

I have 4 different commands in LOOP programming language: y=Zero() y=Val(x)=copy x and put it in register y y=Inc(x)=x+1 y=Dec(x)=x-1 Finally I also have loop n times { ... ...
2
votes
1answer
151 views

LOOP-computable functions

I was just reading a chapter about LOOP-computable functions and I have the following question: Is it possible to numerate every LOOP program with an algorithm? Formally: Is it possible to have a ...
18
votes
6answers
613 views

Visiting points on a number line while minimizing a cost not related to distance

I need some help on this ACM ICPC problem. My current idea is to model this as a shortest path problem, which is described under the problem statement. Problem There are N = 1000 nuclear waste ...
2
votes
1answer
200 views

How to compute amoritized cost for a dynamic array?

I am trying to understand how to do the amortized cost for a dynamic table. Suppose we are using the accounting method. Let A of size m be an array of n elements. When n = m, then we create a new ...
3
votes
1answer
574 views

Convert letters to numbers

I have the following problem. Given A=1, B=2 , ... , Z =26 I need an algorithm that given a letter combination, like the column order in excel, returns me the number/ AA=27 AB=28 ABC? Thanks a ...