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)

-3
votes
0answers
25 views

Algorithm to make sum of elements equal zero [on hold]

I want to make sum of elements in this array equal zero array = [[1, 2, 1], [1, 2, 1]] Need sum of columns and rows equal zero array = [[1, -2, 1], [-1, 2, 1]]
-2
votes
0answers
20 views

MATLAB: Calculating the Jacobian using feval and Newton's Method

Problem: series of equations, each in the form 0 = Fa(i-1) - Fa(i) - k*a(i)*V F, k, V, and a0 are known. Do you have any ideas on how to calculate the jacobian using feval and how to find the ...
-1
votes
1answer
52 views

Pathfinding in a 3d world with obstacles?

What are some methods for pathfinding in a 3d world? Object X needs to move from Point A to Point B but it might have to avoid things like asteroids, planets or gas pockets that makes the object ...
3
votes
1answer
64 views

Consistent snapshot

Suppose process A has a consitent snapshot of some entities. And it is constantly receiving updates for this enteties. Now client B connecting to A and it should receive the consistent snapshot of ...
0
votes
0answers
25 views

Can't figure out how to parallelize the calculation of the amount of offspring expected for species in genetic algorithm

I developed a genetic algorithm in java 8 taking advantage of its reasonably free parallelism opportunities with Streams. As you are likely aware, running the epochs takes its time for even a test ...
-2
votes
0answers
39 views

Find kth smallest element in row wise and column wise sorted matrix [on hold]

One solution I have in mind is that I can construct a min heap of k insert first row/column, then one one by one extract k-1 element from heap and insert new element from corresponding row/column. ...
1
vote
0answers
53 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 ...
-4
votes
0answers
31 views

How to programmatically find or construct good definitions of topics [closed]

I am thinking of creating a program that will automate researching topics. The idea is to have the program google a topic(a word or phrase), and by itself construct a good definition and explanation ...
2
votes
1answer
126 views

General Way to convert a loop (while/for) to recursion or from a recursion to a loop?

This problem is mainly focusing on the algorithm, maybe something abstract and more acedemic;) The example is offering a thought, I wanna a generic way, so example is only used as to make us more ...
11
votes
2answers
335 views

Ant colony algorithm

I am a student working on an ant colony simulator for a course project. The algorithm for it is (obviously) an ant colony algorithm. I know there are various forms of the algorithm but all of those ...
-2
votes
0answers
69 views

Improve your Skills in Algorithm [closed]

If you gonna improve your skills in algorithm in relation to software programming, is it recommended to review counterpart's source code than doing your own hobby project? What is your experience ...
0
votes
0answers
28 views

build list of possible permutations with dynamic set size

I'm trying to develop code/pseudocode to build a list of all permutations given the following data. I'm developing in a java-like language for a web app. I don't have any java libraries for this ...
-3
votes
0answers
107 views

Solving the Travelling Sales Man Problem with Quantum Computers [closed]

I know that it takes billions of years to solve the travelling sales man problem when n = 25 (Number of cities). I am wondering how fast can a quantum computer solve the travelling sales man problem ...
0
votes
1answer
55 views

Using Euclidan Distance to intialize centroid of K-Means

I need to initialize centroid of K-Means using Euclidan distance. Is it possible? If so how the algorithm should be? I have been stuck for a while and couldn't figure it out. Thanks for your time.
0
votes
1answer
48 views

Sorting Sentences by New Words in Each

A very useful learning tool I stumbled across for Chinese was a massive list of sentences that, barring the first 10 or 15, only differed by the ones before by one or two words, or at least as few as ...
0
votes
1answer
147 views

Turn over cards in minimum number of steps

Imagine you're given an array of cards. Some of them are facing down (0), while some of them are facing up (1). Is it possible for given fixed K to turn all the cards face-up by turning over any K ...
-1
votes
3answers
143 views

How “good” are PC randomly generated variables? [closed]

I read that computers count random variables by some algorithm, so the value of the variable is predictable and is called a pseudo random variable. For real randomness one should connect a Geiger ...
0
votes
1answer
39 views

Render order of two-edge directed node graphs

I'm trying to find an algorithm for graphs with the following contents: Nodes with no edges leading out of them (shown here as a red circle) All other nodes have exactly two edges leading out ...
2
votes
1answer
37 views

equal distribution within given set of users

I have a requirement where I have a list of entity and users who that entity can be assigned E1 can be distributed by U1 or U2 E2 must be distributed by U5 E3 can be distributed by U2 ...
2
votes
2answers
253 views

What is a good algorithm to teach time complexity? [closed]

I am trying to teach my friend (who has a web development background) about algorithms. Is there a good problem that you think teaches the concept of time complexity well? It should be intuitive to ...
1
vote
0answers
72 views

GNU Simulated Annealing [migrated]

I'm working from the template program given here: https://www.gnu.org/software/gsl/manual/html_node/Trivial-example.html The program as they give it compiles and runs perfectly, which is nice. What ...
0
votes
1answer
90 views

Creating algorithms [closed]

I am a relatively new programmer. I can pick up languages and learn syntax at a speed that I consider good, but I can't figure out how to solve problems logically using algorithms very well. I know ...
0
votes
1answer
146 views

Check distance between all elements in a list of numbers in O(n*lg(n))

I have an exercise for my algorithms and data structures class, where I basically have to implement a divide and conquer algorithm or function called check_distance to determine whether all numbers in ...
0
votes
0answers
94 views

How do I search the leaves of a tree where each node could have more than two children? [migrated]

I'm trying to search the leaves of a tree data structure for a target value. My function looks like this: def searchLeaves(self, target): #DFS if len(self.children == 0): #is a leaf ...
1
vote
1answer
48 views

Image segmentation - show or hide clusters

I'm trying to make a small program in c#, that will downsample image to specified amount of colors (using K-means). Then, user will be able to hide\show colored areas(clusters) in image. I've ...
0
votes
0answers
62 views

How to search for patterns on a (game)board?

Assume a gameboard with two kinds of pieces. Let the task be to find a common patterns of pieces, namely the patterns that lead to winning. The problem is general, but the game in question is ...
1
vote
1answer
80 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 ...
2
votes
1answer
191 views

When designing a data structure, should I implement very inefficient operations for convenience?

(I've added the .NET tags because the data structures are for .NET, and this question should be considered in the context of the conventions for that platform.) I'm writing a library of immutable and ...
0
votes
2answers
92 views

Add file paths to database

I am scanning a directory of files and want to add them to a database. I have two variants: for file in walk(basedir): files.append(file) for file in files: add_to_database(file) versus ...
4
votes
3answers
142 views

Algorithm that generates a group of men and women who are each interested in everyone from the other gender

In my dating app, I need to compile lists of men and women where all of the men in the list are potentially interested in all of the women in the list, and vice versa. That is, in a list of 10 men ...
3
votes
1answer
174 views

How to draw rectangles for 2D arrays

I have an 2D boolean array that looks like this: [0][0][0][0][0][0][0][0][0][0] [0][0][0][0][0][0][0][0][0][0] [0][0][0][0][0][0][0][0][0][0] [0][0][0][1][1][1][0][0][0][0] ...
3
votes
3answers
507 views

How to model state of leaving/entering home

I have two sensors: One detecting if the door is open or closed, another if movement has been detected in the corridor. I want to detect if the person has left or entered home. Usually the person has ...
0
votes
1answer
107 views

What algorithm can be used to determine order given incomplete information?

Given a series of statements such as: a<c a<b b<c (Read as "a is before b", "a is before c", etc.) What is the order of the elements? In this example, the answer is a<b<c. A less ...
0
votes
2answers
188 views

What machine learning algorithm should I use to build an intelligent reminder? [closed]

I'm trying to build an intelligent reminder application for the mobile platform. I'm new to this and I'm kind of lost. So here's the problem... The application must behave like a personal assistant ...
1
vote
2answers
111 views

Efficient datastructure to create size-limited dictionary

I need a class that acts like a dictionary but will constrain the total number of key/value pairs it contains. For instance, let's say the maximum number of entries is 1000 and the class already ...
-2
votes
1answer
58 views

Find the best shuffle

I am trying to solve the following problem: Question Description: Given four integer numbers A, B, C, and D, a shuffle of them is a zero-index array, which consists of these four numbers in some ...
0
votes
1answer
62 views

How to create good positive and negative images for opencv to distinguish smiling from not smiling? [closed]

My goal is to create an opencv haar classifier xml that distinguishes between me smiling and not smiling. I created images, cut them, showing me smiling and as negatives not smiling. About 5000 ...
0
votes
0answers
60 views

Algorithm for the Simplication and Evaluation of Equations

As a new programmer messing around in python, I've been playing about with writing small programs which can calculate some of the stuff I did in maths at school. I've been trying to think of a way ...
-2
votes
2answers
87 views

Counting digits of a decimal number

Is there an algorithm to count digits of a decimal number other than saving it as a string and then looping to find the decimal point and thus count the digits?
0
votes
1answer
89 views

What's the algorithm should I use for seeing how well 2 strings match?

Suppose I have 2 strings: string1 = "home/lisa/Music/some_files/01.05 - Garden Ground.mp3" string2 = "Music/Jim Smith/Unknown/(Deluxe Version/Garden Ground).mp3" string4 = "Music/Jim Smith/Unknown/00 ...
1
vote
1answer
89 views

More efficient alternative that checks if a list can be made a palindrome

I asked this question on Stackoverflow, but they told me this is the best place to ask. For my algorithms and data structures class, I have to write an algorithm that is more efficient in the worst ...
5
votes
1answer
143 views

Compute Adjacent Pair

I was asked the following question as part of an interview: Integer V lies strictly between integers U and W if U < V < W or if U > V > W. A non-empty zero-indexed array A consisting of ...
-1
votes
1answer
98 views

How to selecting Teams with Minimum Difference between Knowledge Levels

For the below challenge from a programming site, I am bit confused. Problem Statement: A Professor of Physics gave projects to the students of his class. The students have to form a team of two for ...
0
votes
1answer
108 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
86 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 ...
2
votes
2answers
191 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
50 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
148 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 ...
2
votes
1answer
96 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"]}]; ...
1
vote
2answers
137 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 ...