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)

24
votes
8answers
10k 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 ...
2
votes
0answers
127 views
+50

Find sequences in a big data set of integers

I am working on algorithm for solving the integer factorization problem. My goal is to be able to recognize sequence in a big data set of integers. This is my premise, it based on experiments. The ...
8
votes
2answers
5k views

What is the best “bucket-fill” algorithm?

I'm pretty new to image processing, and I am currently working on a paint-like application that will feature a bucket-fill. However, I have no idea what the best algorithm for a bucket-fill is. I ...
-1
votes
1answer
86 views

Algorithm to 'segment' a number into blocks of n?

I'm not sure how to word the title properly, but the problem goes something like this: I have 5 nodes, and node 0 is the "master". User inputs a number, e.g. 100 to the master. master "splits" the ...
0
votes
1answer
39 views

Boundary traversal in binary tree

How to perform boundary traversal in binary tree using only single traversal of the tree? I am doing it in this way (not a single traversal): void printBoundary (struct node* root) { if (root) ...
2
votes
1answer
70 views

What alghorithm can I use to find the biggest subarray within a 2d array with only n different numbers?

Let's say I have a 2d array 100x100 in size, each cell in that array has a number from 1 to 50 randomly. How do I find the biggest subarray in a rectangle size in that array that has only n different ...
0
votes
0answers
82 views

Filtering out images that are in the golden ratio

My goal is to detect images that are probably in the golden ratio - by accident, because I take frames from a video that was taken without the intent of having the images in the golden ratio. My ...
0
votes
3answers
236 views

An algorithm for finding converse duplicates of ordered pairs

Given an array of ordered pairs of values, is there a well-known algorithm to find converse duplicates? [Converse meaning the same values, but in the opposite order.] That is, given ...
-2
votes
0answers
24 views

Permutations of a limited number set

Im trying to find all permutations of a 6 number set given the following limitations. The set contain 6 numbers The sum of the set equals 111 A number is in the range 1 to 36 inclusive I need to ...
0
votes
1answer
81 views

dynamic programming with memoization

I’ve a problem with a programming exercise. I hope you can help me. In this exercise I need to find out what the maximum profit is of taking pictures from several items in a park. For taking pictures ...
0
votes
0answers
10 views

Dynamic Approach For LCA [on hold]

I reading a LCA Tutorial Where it defines P[1,N][1,logN] where P[i][j] is the 2j-th ancestor of i Why it is using logN and why 2j ancestor is used ? I did not understand it's intuition ?
1
vote
2answers
93 views

Estimating run time of algorithm

For instance if i have an algorithm that is O(n2) and it will run for 10 seconds for a problem size of 1000. Now if i were to double the problem size to 2000 i want to know the approximate run time in ...
-1
votes
0answers
34 views

Visiting specific cells of an array

I am trying to implement an algorithm to fill a single dimensional array with the content of the cells from (a,b) to (c,d), (from 0 to `). How could I do this efficiently ? I can't seem to be able to ...
1
vote
1answer
92 views

What algorithm-family or problem-space description fits? Industrial process feeding ingredients to process

Our process continuously feeds (normally <= 8) ingredients from a choice of hundreds, using 3 feeders only. So if ingredient count X is > 3, 3 through X are stirred together in a batch process and ...
5
votes
3answers
213 views

SQL - Algorithm for finding availability of a resource

I'm having trouble creating a mysql compatible algorithm for this. Background App with mysql, perl and JS. It's a booking system where each booking is comprised of a start, end and qty. Start and ...
0
votes
2answers
223 views

Traverse a matrix using a linear index to get an evenly distributed values sample

I'm looking for an algorithm idea on how to traverse a matrix using a linear index while avoiding row/column based traversals to get a more diverse distribution of values. To understand this better, ...
1
vote
1answer
23 views

Matrix distribution to process grid

I need to write a program, which will perform LU-decomposition, etc. The problem is that I don't know about the preferred way to distribute the loaded matrix from the root process to other processes. ...
1
vote
1answer
150 views

Solving a Sudoku variant with an unknown element

I recently stumbled upon a special Sudoku variant and am now struggling to effectively solve it programatically. Consider the following initial 6x6 grid: The rules The red question mark is ...
0
votes
0answers
15 views

Finding Contextual Nodes in a Knowledge Graph [migrated]

I'm currently participating in developing a knowledge graph that uses ConceptNet and a few others as its data sources. It uses the same architecture as ConceptNet namely it is stored as a hypergraph ...
-3
votes
0answers
25 views

DIstribution of unique content [closed]

I would like to distribute of unique content via web browsers. My task is have one part of content (part of movie, chapter in book, ... for example) only on one browser (end user). Another users can ...
3
votes
1answer
121 views

Algorithm to find minimal set

I have a set of sets S and I want to find a minimal set of elements M such that each set in S shares at least one element with M. S = set of sets ∀ f∈S ∃e · e∈f ∧ e∈M For example: S = {{1}, {1, 2, ...
-2
votes
0answers
24 views

NullPointerException from tring to get seperate RGB components [migrated]

I am trying to get the seperate RGB components from each element in a 2D color array,but it keeps throwing a NullPointerException and I am not sure why. It might be something small that I missed, so ...
30
votes
10answers
6k views

Is it reasonable to assume that any physical quantity can be represented by a 64-bit integer without overflow or underflow?

The original binary search algorithm in the JDK used 32-bit integers and had an overflow bug if (low + high) > INT_MAX ...
0
votes
0answers
22 views

PSO – how Dimensions are set up?

I am coding a Particle Swarm Optimization in C++. I have been for days trying to understand the theory of how dimensions work in each different problem. In the many examples I have seen, all of them ...
0
votes
1answer
49 views

Algorithm Space and Time Complexity with Consideration for I/O (eg cache)

Is there an expression of performance for an algorithm or data structure that attempts to consider cache and other hardware concerns? Context: in my class we're looking at binary trees and it seems ...
1
vote
0answers
54 views

Traversing game state space : more search leads to bad results [migrated]

I am cross posting this question from codereview as i found that it to be non-responsive. I am trying to solve a problem which i think is TSP on a 2-D grid. So, i am trying to get the best result ...
2
votes
1answer
186 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 ...
4
votes
4answers
540 views

Need help identifying a league scheduling algorithm

I am trying to create a sports league scheduler. I am having trouble identifying an algorithm to help me efficiently fill in each slot. Sample data to build the schedule would be: 10 teams Each ...
2
votes
1answer
57 views

timed events to modulation of real-time audio

I am new very to audio programming and am having trouble figuring out the right kind of algorithm for converting control events (e.g. like MIDI) to real-time sound genesis with a buffer. At the ...
1
vote
1answer
53 views

Connected components of undirected graph

Suppose I have an undirected graph G with vertices v1...vn and edges. Right now it is in adjacency list representation. For every time moment I have as input some subset of vertices that are "active" ...
0
votes
2answers
87 views

MJRTY - A Fast Majority Vote Algorithm isn't work [closed]

The MJRTY algorithm sets out to solve the problem of finding the majority element in a stream (an element comprising more than 50% of the stream). Moore proposed to solve this by using only 2 pieces ...
0
votes
3answers
241 views

Abstraction in algorithms

I asked some questions about algorithms, and some replied they are abstract concepts, however I don't know what abstraction means for algorithms or how it applies. For objects, I know if we remove ...
1
vote
0answers
53 views

A fast algorithm for a simple multi-objective minimization?

I have a set of n (arbitrary) integer numbers S which I want to partition into k subsets S_i each of size n/k (you can assume that k divides n). Let A be the arithmetic mean of elements of the set S. ...
3
votes
1answer
52 views

Should changes to FNV-1A's input exhibit the avalanche effect?

This is kind of related to Which hashing algorithm is best for uniqueness and speed?. In that question, the excellently written top answer notes, Randomnessification The other subjective ...
0
votes
1answer
124 views

Would adding more digits be a way to scale a order generation service? [closed]

I am working on interview questions from Amazon.com Software Development Engineer Intern Interview Questions. One of the interviewees was asked "give a scalable system design of Amazon.com's order ...
34
votes
9answers
6k views

Why is it impossible to produce truly random numbers?

I was trying to solve a hobby problem that required generating a million random numbers. But I quickly realized, it is becoming difficult to make them unique. I picked up Algorithm Design Manual to ...
3
votes
2answers
136 views

How to iterate through all permutations of valid links between nodes

Imagine a 2D area, with a number (array) of nodes (or points) defined within it, in arbitrary (but known) positions (integer x,y coordinates), like this: From there I want to be able to, ...
1
vote
2answers
130 views

c++11 random: why different range of int and real?

In the c++11, we now have <random> to produce random number. About uniform distributions, we have following int_distribution and double_distribution: uniform_int_distribution-produces integer ...
0
votes
2answers
113 views

What is a formal definition for an algorithm step?

Consider the following code to find the K th minimum element of an array: FindKthMin(A[], k) { A = Sort(A); return A[k]; } Could it be an algorithm without specifying the sort details? ...
1
vote
2answers
155 views

What benefit is there to using recursive binary search over iterative binary search or vice versa?

In a recent assignment for my programming 2 class we tested the efficiency of searches by populating a java ArrayList with 13,040 strings. The sequential search was obviously slower than the binary ...
0
votes
0answers
27 views

Finding the largest bundle of flagged points

I am currently working to develop a program that takes in an array of 4 columns and around 200,000 rows. Each column represents x, y, z (coordinates), and a flag denoting whether or not this point is ...
4
votes
2answers
163 views

Number of strings containing a specific substring

I've seen numerous questions (and answers) concerning the number of binary strings (e.g "10010" containing some binary substring (e.g "00"). I'd like to know if there is a way to generalize this: ...
0
votes
2answers
224 views

Is recursion a declarative approach to solve the problems?

I have noticed many problems in algorithms textbook are solved by recursion (divide and conquer, backtracking,...) As I tried to enhance my skills in writing them, I have noticed, I just need to ...
3
votes
1answer
224 views

What is the most efficient / fastest way to keep a list in order?

I implemented Dijkstra's path finding algorithm in JavaScript and a big part of it involves storing the distances to nodes and fetching the smallest. The distances change often and the smallest is ...
20
votes
10answers
2k views

Do algorithms depend on computer architectures?

I read somewhere (forgot which book it is) that algorithms are independent of computer architectures. Some even say algorithms are themselves computation (machines?)? On the other hand, books on ...
0
votes
2answers
44 views

Approaches to get stats like average latency in last N seconds

I am receiving messages with latency information (LI, {date, latency}). For statistical reasons: (I am open to approx. approaches, stats monitor will be updated in 6-60 seconds) I want to monitor ...
6
votes
3answers
164 views

number of strings, when each character must occur even times

I've been bashing my skull at this problem for some time now, and its really starting to frustrate me. The problem is: I have a set of characters, A, B, C, and D. I have to tell in how many ways a ...
2
votes
1answer
4k views

faster algorithm for finding all subsets

This is the algorithm (pseudocode) I have right now for finding all subsets for a given set with length k: void allSubsets(set[]) { for (i = 0; i<k; i++) { for (j = i + 1; j<k; j++) ...
0
votes
2answers
123 views

Why is the “period of a (pseudo)random number generator” important?

I've been trying to understand (pseudo)random number generator code from various sources and the concept of the period continues to elude me. To satisfy the minimum level of understanding, I've tried ...
1
vote
1answer
70 views

Algorithm for a fast search

I am looking for an algorithm (pseudocode, R code) for my problem here. This looks like a lot to read but is actually very very easy to read, and I am just trying to be verbose. I have a list (say ...