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
1answer
49 views

Need an algorithm to filter this collection format

I'm sorry the title is so vague ... I cannot think how to describe it any better. I have a collection in this format: var myCollection = [{id:"a"}, {id:"b",excludes:["a"]}, {id:"c",excludes:["b"]}]; ...
3
votes
1answer
184 views

How can I approach creating an efficient algorithm for maximizing value with these specific constraints?

I'm having trouble coming up with an approach that isn't n^2 for this problem. Here's a contrived, simplified version I've come up with: Let's say you're a company that needs 4 employees to launch in ...
0
votes
1answer
71 views

Line intersection detection algorithm

I'm trying to detect if a line drawn by the user intersects itself. I'm using a line intersection detection algorithm that goes through each waypoint of the line and checks if intersects with any ...
2
votes
0answers
156 views

What algorithm is this?

I have some vague recollections from my algorithms courses, but nothing specific comes to mind. let S be a multiset of things we are interested in. As input, we get T, s1, s2, ... sn, all of which ...
-2
votes
0answers
14 views

knapsack problem using greedy [on hold]

I have a code for knapsack problem using greedy but is is not the best optimal option and does not work very well. Can someone give me an optimal idea for this? #include <iostream.h> int o[50]; ...
-5
votes
0answers
40 views

Find all permutations of a set of 6 numbers

I'm trying to find all permutations of a set of 6 numbers 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 ...
0
votes
1answer
277 views

Calculate reachability of one point from another

I have an array which stores a set of positive x coordinates in sorted way, say arr={1, 4, 5, 9, 12, 45} etc. And I have a maximum distance k which I can go from one point to another point let ...
0
votes
0answers
26 views

python: area mapping using trigonometric circle

I have a car controlled by a raspberry pi, I would like to create maps to each place it visits. The solution I came up with is simple. Lets say you tell the car to go forward and then after 5 minutes ...
0
votes
1answer
98 views

Min weight feedback edge set with DFS?

Exercise from The Algorithm Design Manual 6-10. [4] Let G = (V,E) be an undirected graph. A set F ⊆ E of edges is called a feedback-edge set if every cycle of G has at least one edge in F. ...
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
149 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
92 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
42 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
73 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
92 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
237 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 ...
0
votes
1answer
84 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
97 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
215 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
225 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
152 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
27 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
51 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
541 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
243 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
56 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
131 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
138 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
28 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
164 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: ...