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)

4
votes
0answers
60 views

Python rectangle packing

I'm working on a project which involves packing multiple rectangles in a larger rectangle(the bounding box). Rectangles can't overlap with each other or with the boundaries of the bounding box. ...
1
vote
2answers
69 views

Efficient range search for pair of numbers

Assume we have large list of pairs: struct {x: double, y: double} pair; vector<pair> What is the most effective way to find all pairs where (x1 < x < x2) AND (y1 < y < y2)? O(n) ...
2
votes
0answers
42 views

Graph visualization algorithm

I need a 2d or 3d graph visualization algorithm by which adding/removing a node or a relationship does not have a butterfly effect on the positions of other nodes. (We are talking about a directed ...
5
votes
2answers
180 views

Algorithms for allocating N balls into M boxes

Every box has at least no balls and at most N balls. Of course the total number of balls in M boxes must equal to N. For each allocation, I calculated a value based on the allocation: ...
-2
votes
2answers
130 views

Some people told me that finding all prime factors of a number is an unsolvable problem. Is that real? [on hold]

I'm a beginner, so I spent a lot of time trying to solve the 3rd problem on projecteuler.net, which is: "Find the largest prime factor of 600851475143" Now, I imagined it would be more useful if I ...
3
votes
2answers
123 views

Is it possible to speed up a hash table by using binary search trees for separate chaining?

I want to implement a Hash Table using Binary Search Trees to reduce the search complexity in the Separate Chaining process from O(n) (using linked list) to O(log n) (using BST). Can this be done, and ...
1
vote
1answer
65 views

Sorting a large number of unknown items with multiple stacks

Here is a problem I'm trying to solve for a personal project. I'm not exactly sure how best to even approach it. Problem: I have a single stack already populated with several thousands of unknown ...
-3
votes
0answers
34 views

What approach to develop a bot player for the Trax game? [on hold]

I have created a fully functional two player game of Trax. It is a Linux console application, written in c++, which saves the current state of the board into a binary file, which in turn can be used ...
0
votes
2answers
96 views

Is studying algorithms important for game development? [on hold]

I am fairly new in the programming world, I have a 1-year experience and I learned by watching online courses, and I made few iOS apps. Now I am moving into game development and I already ...
2
votes
3answers
79 views

MaxHeap-like data structure supporting max AND min, also decrease-key (yes decrease-key)

For the purpose of implementing an optimization algorithm (finding the minimum of a multivariate function) I want to create a data structure that supports the following operations: load from array ...
-2
votes
1answer
24 views

Algorithm to generate parallel path inside polygon

A path is defined as a list of 2D points (x,y) (and may be open or closed). Given a path p, what is an algorithm which generates a path p' which is "inside" p and at constant offset to p i.e. each ...
-2
votes
1answer
52 views

Pairing 40 people over 20 days such that no pair is the same twice or more [duplicate]

I'm trying to figure out what algorithm / method I can use to figure out how to pair people together such that the pairs aren't repeated i.e. if a unique individual is denoted by Px where x is their ...
2
votes
3answers
159 views

Close to knapsack problem?

I think that I am trying to solve a problem somewhat similar to a knapsack problem. I am not sure though. Please see the input given below and my solution. There are three types of items and 4 ...
1
vote
0answers
74 views

Smallest number of rectangles covering marked parts of grid

I have an N by N grid of cells, and certain blocks are marked: +--+---+---+---+ | | | | | | | x | x | | | | x | x | | | | | | | | | | | x | +--+---+---+---+ I would like to ...
1
vote
1answer
125 views

Increment or double problem

I have a problem with an assignment. In this assignment I have to create a program which needs to calculate how many different possibilities are there to get from number a to b. To get from a to b you ...
0
votes
0answers
44 views

Combining items from several lists with pagination

I am trying to come up with an algorithm for getting items for a news feed from several sources. There are multiple lists of data: S1, S2, ... Sn. Each of these lists has a certain known amount of ...
0
votes
1answer
33 views

Split multiple overlapping intervals to non overlapping intervals

currently I try to build an algorithm to split an array of overlapping intervals to a new array with non overlapping intervals. For example: Array of overlapping intervals: [ {0,7}, {8,12}, ...
1
vote
4answers
151 views

List comparing techniques for faster performance

I need to cross names from two lists, and find all occurrences of one name in the other. The lists are too big, one have 50k elements and the other 400k. For a small list I would use two foreach ...
0
votes
1answer
61 views

Translation algorithm - combinations to indices

I have a deck of 52 poker cards represented as array of int - [0, 1, ... 51]. There are 2.598.960 possible combinations of 5 cards. I can generate all combinations like this: #id #combination ...
0
votes
0answers
46 views

scrabble solving with maximum score

I was asked a question You are given a list of characters, a score associated with each character and a dictionary of valid words ( say normal English dictionary ). you have to form a word ...
0
votes
5answers
479 views

Fastest way to determine if a value is in a list?

I'm aware there may not be a good solution to this problem. I'm looking for a fast algorithm that determines whether or not a value (let's say an integer) exists in a set of values, however I need the ...
2
votes
3answers
172 views

fast, say O(log2(N)), sliding median algorithm

So I know how to do a fast O(log2(N)) sliding max or sliding min algorithm. Brookes: "Algorithms for Max and Min Filters with Improved Worst-Case Performance" IEEE TRANSACTIONS ON CIRCUITS AND ...
-2
votes
0answers
22 views

generating best fit from 3d datapoints [closed]

given N datapoints of point(x,y,z) how should I go about generating the best fit line for this dataset? Accuracy is more important than speed as the collection of best fit lines will be precomputed ...
1
vote
1answer
160 views

Calculate Big-O for nested for loops

I found this nested loop to calculate the Big-O notation. for(i=0;i<n;i++) for(j=0;j<i*i;j++) for(k=0;k<j;k++) I got the time complexity for the algorithm with this polynomial ...
-5
votes
0answers
25 views

How to do machine learning ensembling [closed]

I want to know how machine-learning-ensemble is done. how can I ensemble out put of logistic regression and support vector machine.
-1
votes
0answers
29 views

Comparing and adding (math) integers in an array [closed]

Long time Front-End Dev, new-ish to core programming theories. I am trying to solve a problem, but mentorship to gain better language is needed to progress. Write a method to return the minimum # of ...
0
votes
0answers
14 views

Polling more recent / active items more frequently

I'm setting up a service that is meant to query, via a rate-limited API, a number of posts in real-time. Now, some of these posts can be several months old, and they should really only be queried, ...
0
votes
2answers
135 views

Is there a approximate string comparison function which is odd like mathematical functions are odd?

I say odd like a mathematical function, a mathematical function is odd if f(-x) = -f(x) I understand that comparing two strings may seem to have little to do with this, because the arguments cannot ...
0
votes
0answers
46 views

Compare names and the use of Levenshtein's algorithm

I need to cross names from two lists. What is the best away to compare the names? As you may expect, in one list we can have the complete name, on the other just the first and last. Besides that, ...
0
votes
3answers
149 views

Does it really need to convert decimal,string, etc to binary?

I'm very new to programming. Just read some articles about algorithm for converting a decimal or string to binary. But,according to what I know, computers hold these data in binary form. So why don't ...
1
vote
1answer
77 views

How to count sort comparison

When it is said that this sort has M number of comparisons what does it mean? As an example: procedure bubbleSort( A : list of sortable items ) n = length(A) repeat swapped = false ...
0
votes
2answers
79 views

Average number of comparison for sort algorithms

I need to write different sort algorithms such as bubbleSort insertionSort selectionSort quickSort mergeSort And measure how many average comparison does each one for N number (averaging between ...
2
votes
0answers
83 views

Asking questions to the user based on results of previous questions

I have to select a question that would help me make me sure the user knows about a given subject. As an example, let's assume the user hasn't answered any question yet. Every question has a scope ...
2
votes
0answers
63 views

Can't figure out class scheduling issue? [closed]

"You are a college advisor trying to help students plan their academic careers. You have the list of courses in each major and their prerequisites. Students often want to take their major courses as ...
0
votes
0answers
45 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. ...
-2
votes
1answer
63 views

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

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 ...
9
votes
9answers
2k 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 ...
-1
votes
1answer
57 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
69 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
30 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 ...
1
vote
0answers
69 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 ...
2
votes
1answer
139 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
414 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
0answers
29 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
56 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
52 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
191 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
144 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
40 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
40 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 ...