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.
1
vote
1answer
68 views
Best algorithm for “ACM ICPC Team”
I have this problem (complete description):
There is a list of persons N and M topics.
I have to find out the maximum number of topics a 2-person team can know. And also find out how many teams can ...
0
votes
1answer
47 views
How to determine whether two trees (not necessarily binary) are isomorphic
Two ordered trees T' and T'' are said to be isomorphic if one of the following holds:
◦ both T' and T'' consist of a single node
◦ both T' and T'' have the same number k of subtrees, and the ith ...
-1
votes
0answers
54 views
Breaking Loops in Monte Carlo Simulation [on hold]
I'm writing a code in python to test a search method. As you can see, the code has a method which uses breaks and then, out side of that, I run this method 1000 times to try and get the average ...
2
votes
2answers
126 views
String Searching algorithm
A title for a movie can be ambiguous. (Eg. The Lord of the Rings, Lord of the Rings, Lord of the Rings, The)
There exists a database entry that has a list of movie titles mapped to a unique ...
0
votes
0answers
39 views
All clustering possibilities for a graph
Is there a known algorithm for finding all clustering possibilities for a directed graph?
EDIT:
By cluster i mean a weakly connected sub-graph G, so that E(G) > 0.
By a clustering possibility I ...
0
votes
1answer
122 views
Program to look at the first say 5 characters of a word and return a string if that string is actually the first 5 characters of a word?
For example, say I have a string and it has the letters:
RDNAL
This is not an actual English word or it doesn't start an actual english word, so the program would skip this string and would avoid ...
-3
votes
1answer
48 views
Are structures linear data structures or non-linear? [on hold]
I am a student of Computer System Engineering. We are studying data structures and algorithms. I want to know that are structures linear data structures or non-linear? Please explain me why they are ...
-4
votes
0answers
38 views
Algorithm for Creation of dictionary in c [on hold]
Here we have to develop the algorithm for creating the mini dictionary and compare the string which we had given as input, whether the dictionary contains a given string or not?
2
votes
1answer
84 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"]}];
...
0
votes
1answer
82 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
181 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
20 views
knapsack problem using greedy [closed]
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]; ...
0
votes
0answers
30 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 ...
-1
votes
1answer
97 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 ...
-2
votes
0answers
104 views
Filtering out images that are in the golden ratio [on hold]
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 ...
2
votes
1answer
84 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 ...
-5
votes
0answers
44 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
0answers
10 views
Dynamic Approach For LCA [closed]
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 ?
0
votes
1answer
85 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 ...
1
vote
2answers
98 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
35 views
Visiting specific cells of an array [on hold]
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 ...
0
votes
1answer
44 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)
...
1
vote
1answer
24 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. ...
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
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 ...
5
votes
3answers
221 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
0answers
23 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 ...
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 ...
0
votes
1answer
55 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 ...
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
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 ...
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" ...
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
59 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
142 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 ...
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
117 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
157 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 ...
3
votes
2answers
142 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, ...
0
votes
3answers
244 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 ...
3
votes
1answer
225 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 ...
0
votes
2answers
230 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 ...
0
votes
2answers
45 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 ...
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
124 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
73 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 ...
4
votes
2answers
182 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:
...