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)

5
votes
9answers
1k views

Big O Question about an algorithm with (n^2 + n) / 2 growth rate

I'm asking this question because I am confused about one aspect regarding big O notation. I am using the book, Data Structures and Abstractions with Java by Frank Carrano. In the chapter on the ...
0
votes
0answers
18 views

Efficient all-pairs set intersection on GPU

I have n sets, subsets of a finite universe. I want to calculate the n*n matrix in which the (I, J) entry contains the cardinality of the intersection of set I and set J. n is in the order of 50000. ...
3
votes
2answers
216 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
0answers
84 views

What algorithm to convert an integer to unique non-linear string? [on hold]

What algorithm that can be used to convert a 32-bit integer to a unique non-linear string? For example: 1 -> DGKJUFD21 2 -> IDFMSOF89 3 -> GDSJH83AS and so on.. This is linear string: 1 ...
2
votes
2answers
377 views

Reduce a list of IPv4 to lowest common CIDR

I have a long list of IP addresses that show some pattern of closeness Example: XX.249.91.16 XX.249.91.21 XX.249.91.32 XX.249.91.160 XX.249.91.165 XX.249.92.15 XX.249.92.25 ...
-1
votes
0answers
22 views

Rating formula including rating and number of votes [on hold]

Is there any other formulas for rating calculation besides IMDB one? I have 10-stars rating TOP-100 chart, and what in that chart that for example entry with rating 9.6 and 56 number of votes would be ...
-2
votes
1answer
51 views

What do I need to parse sentence for a “simple bot” [on hold]

I am developing a chat bot with Node.Js. I am trying to find efficient way to parsing sentence. what do you think about humanity -> ba bla bla. what do you think about cats ->I love cats ...
1
vote
0answers
204 views

Karger's algorithm for bin-packing?

I first came across that algorithm as the "Random minimum cut" algorithm. And recently a colleague was trying to pack a big quantity of small textures into one image file. Then it clicked - why not ...
13
votes
5answers
4k views

What would be the Impact of P=NP? [closed]

I am preparing for a test and I can't find a clear answer on the question: What would be the impact of proving that PTIME=NPTIME. I checked wikipedia and it just mentioned that it would have "profound ...
11
votes
2answers
1k views

Converting a bounded knapsack problem to 0/1 knapsack problem

I ran across a problem where goal was to use dynamic programming (instead of other approaches). There is a distance to be spanned, and a set of cables of different lengths. What is the minimum number ...
-3
votes
0answers
33 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]]
1
vote
2answers
119 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 ...
17
votes
3answers
1k views

Java and .NET: Why different sorting algorithms are used by default?

Just wondering why Java and .NET Framework uses different sorting algorithm by default. In Java Array.Sort() uses Merge Sort algorithm by default and as Wikipedia.com says: In Java, the ...
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 ...
-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
53 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 ...
1
vote
4answers
2k views

Time-complexity of nested for loop

I have loops like this: for(int i = 0; i < n; i++) { for(int j = 0; j < i; j++) { sum += 1; } } It's O(n * ), but I'm not sure what the j < i loop is. I have some tests ...
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
43 views

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

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
60 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
128 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 ...
12
votes
2answers
374 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 ...
0
votes
2answers
348 views

How are the tiles in WORDAMENT organized?

I'm trying to create a word game, just like WORDAMENT, in my spare time. In order to present a new round, I need to create a board with 16 letters organized in a 4*4 grid. Currently, I'm generating ...
0
votes
1answer
71 views

Measure and locate areas of similar value in an image

I saw this picture online and wanted to see if I could create an algorithm to give ordinary images an effect like this: http://justinlivi.net/wp-content/uploads/2011/01/Living_In_Digital.jpg My idea ...
2
votes
2answers
279 views

Algorithm for detection of overlapping between vectors

I am currently developing a math-physics program and I need to calculate if two vectors overlap one another, the one is vertical and the other is horizontral. Is there any fast algorithm to do this ...
-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 ...
7
votes
1answer
361 views

How do personal assistants typically generate sentences?

This is sort of a follow up to this question about NLG research directions in the linguistics field. How do personal assistant tools such as Siri, Google Now, or Cortana perform Natural Language ...
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 ...
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
142 views

Dynamic Programming Problem - To find smallest integer number 'x' which contains only digits 1's and 0's such that x mod n = 0

To design an algorithm that will output the smallest integer number 'x' which contains only digits 1's and 0's such that x mod n = 0 and x > 0..... For example: 2 divides 10 3 divides 111 4 ...
0
votes
1answer
87 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 ...
0
votes
1answer
49 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 ...
45
votes
4answers
8k views

Which algorithms/data structures should I “recognize” and know by name? [closed]

I'd like to consider myself a fairly experienced programmer. I've been programming for over 5 years now. My weak point though is terminology. I'm self-taught, so while I know how to program, I don't ...
0
votes
2answers
321 views

How can I rank teams based off of head to head wins/losses

I'm trying to write an algorithm (specifically in Ruby) that will rank teams based on their record against each other. If a team A and team B have won the same amount of games against each other, then ...
0
votes
1answer
149 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 ...
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 ...
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 ...
1
vote
1answer
6k views

Quicksort and middle pivot

I am having a head ache understanding quicksort with middle pivot. I found lot of explanations about using left most or right most, but not many about a middle one. Can I safely assume these?: If ...
-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 ...
1
vote
3answers
5k views

Why does a proportional controller have a steady state error?

I've read about feedback loops, how much this steady state error is for a given gain and what to do to remove this steady state error (add integral and/or derivative gains to the controller), but I ...
1
vote
0answers
23 views

How to use an Address Gazatteer in an application that contains addresses [closed]

Say I had access to the post office address file (http://en.wikipedia.org/wiki/Postcode_Address_File) and wanted to cleanse about one million addresses. I am trying to think of an "algorithm" to do ...
0
votes
4answers
361 views

An algorithm for finding converse duplicates of ordered pairs

Given an array of ordered pairs of values, what algorithm will find converse duplicates? [Converse meaning the same values, but in the opposite order.] That is, given [ab,ac,ad,bc,bd,ca,db] is there ...
3
votes
2answers
244 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 ...
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 ...
1
vote
3answers
214 views

What algorithm 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
1answer
138 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. ...
6
votes
3answers
8k views

elevator algorithm and implementation [closed]

I wanted to know how (real) elevators work. But, so far, I could not find much material about the algorithms they use, nor software (if any) for simulation. Could anybody give me references for that?
0
votes
1answer
149 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 ...
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 ...