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)

0
votes
1answer
29 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
19 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
4answers
314 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
0answers
19 views

generating best fit from 3d datapoints [on hold]

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
votes
0answers
23 views

generalize expansion rate of 3d points using previous data. Algorithm construction

I have sets of data containing the coordinates for a point. The first two datasets i'm using to define a rate of expansion for the z coordinate. This rate will be linear over the space. How should ...
1
vote
1answer
142 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
22 views

How to do machine learning ensembling [on hold]

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
22 views

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

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
128 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
40 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
144 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 ...
2
votes
1answer
71 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
70 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
67 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
61 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 ...
-1
votes
0answers
63 views

How do you recognize when topological sort shoudl be used? [closed]

What are the general properties of a programming problem that hint to the necessity of topological sort?
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. ...
-1
votes
0answers
27 views

Rating formula including rating and number of votes [closed]

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
61 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 ...
0
votes
0answers
94 views

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

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 ...
-3
votes
0answers
38 views

Algorithm to make sum of elements equal zero [closed]

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
22 views

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

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
55 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
68 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
28 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
65 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
411 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
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
51 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
187 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
38 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
256 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
94 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
153 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
49 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
63 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
194 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
95 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
145 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
2answers
200 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
509 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 ...