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
3answers
126 views

How to model heuristic uncertainty when sorting data?

Sorting algorithms assume you have a defined comparator. For example, if sorting integers A and B, the A > B operation allows you to determine if A should be after or before B. Imagine you want ...
0
votes
1answer
295 views

Laravel Algorithm for taxi app

I am trying to write a backend for a taxi service (university assignment) and I am stuck on the algorithm. whenever a new client posts a request, all the taxi drivers nearby get an email notification ...
2
votes
2answers
220 views

O(1) complexity array access

I have an array of heights, with irregularly spread stations, e.g.: arrH=[100 500 1000 2500 4500]. During run-time I receive some height, h, and I need to determine which cell (index) contains the ...
2
votes
3answers
221 views

A better way than O(n^2) for traversing a dictionary of dictionaries.

I have a Dictionary of Dictionaries that I need to traverse to find two records with various matching parameters. I have two foreach loops to do this which is O(n^2). I am looking for inspiration to ...
0
votes
0answers
90 views

Best datastructure to use

I am using Amazon's dynamodb nosql database and as a result I need to think of some ways to do certain operations to fit into their limits (e.g 4k item limit, can't combine small items into the same ...
5
votes
2answers
248 views

How to optimize/parallelize the following clustering/joining algorithm:

I have relatively-small algorithm that takes up ~60% of the total run-time of my scientific code (57 lines of 3600), so I would like to find a way to optimize what I'm doing and make the code order-...
0
votes
0answers
77 views

Algorithms for realistic path animation?

I have written some code that generates a set of paths of an object through a number of obstacles. You could imagine it as dozens of permutations of the path a formula one car takes through a twisty ...
3
votes
1answer
96 views

Are these graph coloring algorithms equivalent?

Suppose you want to color the vertices of a graph in a greedy fashion, given a predetermined order of these vertices. The goal is to avoid giving two adjacent (linked by an edge) vertices the same ...
-1
votes
2answers
123 views

Merging Sorted Lists (with no comparison function)

I have a few lists of items (which will likely but not necessarily have common elements). The lists are known to be sorted, but don't have a comparison function (they were manually put into the system ...
-1
votes
1answer
535 views

Grid walking explanation [closed]

There's a problem on hackerrank.com called Grid Walking. Here is its description: You are situated in an N dimensional grid at position (x1,x2,...,xN). The dimensions of the grid are (D1,D2,......
0
votes
2answers
101 views

Search Algorithm Question

I need to retrieve five stars from a group of stars so I can hide them by turning their visible flag to “false”. I know the x, y coordinate value of each star I am looking for. My algorithm opens a ...
0
votes
0answers
43 views

What algorithm to use to count realization of high combinatorics setup?

I'll use the MobA games to illustrate what I'm asking since it's easier to explain even tho I want to apply that algorithm to time series. In a MobA game you have more than 100 characters and every ...
1
vote
1answer
108 views

Algorithm for creating a looping 3D path that complete fills a cube [closed]

I'm creating a game world that consists of a 16 x 16 x 16 rubix cube (pictured), where the individual cubes are floating in space. The cubes continuously move along a single set path that links up ...
1
vote
0answers
91 views

Belman-Ford 2d array variation problem

I've got a problem with applying a Bellman-Ford algorithm to 2D Array (not to graph) Input array has m x n dimensions: s[1,1] s[1,2] ... s[1,n] -> Exit s[2,1] s[2,2] ... s[2,...
32
votes
5answers
5k views

Why is deletion usually much harder to implement than insertion in many data structures?

Can you think of any specific reason why deletion is usually significantly harder to implement than insertion for many (most?) data structures? Quick example: linked lists. Insertion is trivial, but ...
-1
votes
1answer
117 views

Drawing the Line between Coding Style and Algorithm [closed]

Formatting with Indentations, White spaces, and New Lines obviously fit into the coding style category. if (a == b) { foo(); } // vs if (a == b) { foo(); } On the other hand, something ...
0
votes
0answers
108 views

Minimum of Overlapping Intervals

we have a 1-d space [1...N]. We are given M intervals of the form [L(i), R(i), C(i)] for 1 <= i <= M, where L(i) is the left most point, R(i) the rightmost and C(i) the value of that interval . ...
2
votes
1answer
91 views

What's the name of the algorithm to balance an acyclic graph?

Algorithms class was a such a long time ago and I can't remember the name of the algorithm to balance an acyclic graph. Let's start with a graph that looks like this: 1 | 2 ...
0
votes
0answers
126 views

What is this compression algorithm? (Similar to RLE)

In Run Length Encoding (RLE), a large set of information is encoded by storing the quantity of consecutive sequences. A canonical example is: ...
-2
votes
2answers
98 views

Find index of string in an array of strings where overlap could occur

I am having some trouble writing a variant of sub-string search. Essentially the goal is to write a method that can perform sub-string search except that the source data is in an array of Strings ...
0
votes
1answer
264 views

How to test an algorithm with multiple inputs?

I want to check group of algorithms which has up to 8 input options. The native idea would be to check all possibilities via brute force. How can I reduce it without leaving out required combinations? ...
1
vote
2answers
168 views

Refactoring method with nested loops and 6 variables [duplicate]

I have a method which implements a small section of a (complex) algorithm. This algorithm has taken me several weeks to perfect and is by far the fastest method I can find. The method in question has ...
2
votes
1answer
76 views

Running time of the specified Bubble Sort Algorithm

I have been working on a few algorithm questions the last few days, and one bubble sort problem in particular has been giving me headaches. for (k=1; k <= A.length - 1; k++) { //Line 1 ...
-2
votes
3answers
108 views

Link to ISO doc? Complexity of unordered_map operations in C++::stl [closed]

In different forums, I have found the statement that in C++::stl, insert and find for unordered_map have guaranteed amortized time complexity O(1). This puzzles me, and I would like to see the ...
0
votes
0answers
34 views

Pseudorandom in Android

I am building a security mechanism and I need a Pseudorandom functionality in my app. More particularly I need to convert a String to fix length. My strings are random already, they just to long so I ...
-1
votes
2answers
204 views

Gödel's Incompleteness Theorem and Algorithms [closed]

According to Gödel's incompleteness theorem, not every problem can be solved using algorithms. How do we know if a problem can be solved using algorithm? How do we know that NP problems are ...
1
vote
0answers
103 views

Finding the longest acyclical path in a 2D maze

I have a n by n maze, like this: [0, 1, 0, 0, 0, 1] [1, 1, 0, 1, 1, 0] [1, 0, 0, 1, 0, 1] [0, 1, 1, 0, 0, 1] [0, 0, 0, 1, 0, 1] [1, 0, 1, 0, 1, 1] Only 0-fields are passable, and one can only move ...
1
vote
0answers
74 views

Generate a fixed length number hash from a number

Let say I've a fixed length number, e.g. 6 digit: 837493, I want to apply some process (with a salt), and generate a new number of another 6 digits, e.g. number = 837493 another = hash(number + ...
1
vote
3answers
272 views

What's the big-O complexity of this recursive algorithm?

I am following a course of Algorithms and Data Structures. Today, my professor said the complexity of the following algorithm is 2^n. I waited till the lesson was over, approached him and told him ...
1
vote
0answers
87 views

distribute rectangles in order to do not overlap

I've a series of labels and icons inside the screen. A label is on the right of corresponding icon. I must perform a sort of declutter: when two or more labels overlap each other (or a label with an ...
0
votes
5answers
432 views

How do I avoid having to compute square roots for every element in a data set?

I have a list of points, with floating point coordinates, of which I've computed the square of the Euclidean distance between these points. I have not computed the actual Euclidean distance between ...
0
votes
2answers
403 views

Does algorithm design belong to software engineering? [closed]

In academic meaning, it seems to me that algorithm design is studied in a high/abstract level of computation (computability, complexity), although software engineering is also studied in high/...
0
votes
2answers
139 views

What is a readable algorithm for selecting a random buyer based on what they purchased?

I am working on a giveaway algorithm to select a customer based on what they purchased: If they purchase item 1, they gain 1 point. If they purchase item 2, they gain 2 points. If they purchase item ...
2
votes
1answer
179 views

Best approach to implement multiple levels of difficulty to a minimax AI [closed]

I'm programming a game (turned base, in a grid) for which I implemented an AI using the minimax algorithm (with alpha-beta prunning). It's all fine and working, but the AI is too good and I can't win ...
1
vote
0answers
77 views

Algorithm for evaluating line breaks efficiently [closed]

Consider following problem : Given: String input with the length n Font(-metrics) - potentially slow in usage Bounds of an abstract Textview which shall contain the text in a specific manner: e.g ...
0
votes
2answers
105 views

Anonymize Public Health Records Database

I am working on a project to anonymize PHI in our health records database when databases are copied to our testing environments. Currently, the database is copied and fields in the tables (first name, ...
2
votes
0answers
115 views

Predicting package delivery schedules

I'm trying to solve the following problem: A delivery man has N packages to deliver, already sorted. He starts the route at start_time, he works until end_time. I have historical data of his ...
4
votes
3answers
190 views

Algorithm to determine best combination of keeping students together in their camp rooms

I have a problem I'd like to solve and am not sure whether there is a known algorithm or how the best way to approach it would be. Say for example there is a class of 30 students who are going on a ...
3
votes
0answers
152 views

How to distribute a number of elements in a bucket so that it is within a range?

I have 50 elements n1, n2, n3, ... , n50 and a limited number of buckets, say 5 buckets and each bucket can hold a range from, say 100 to 150 only (which is nothing but the sum of the elements in that ...
4
votes
1answer
206 views

Optimal fixed-size sequential sorting algorithms

I have been working on sorting algorithms for a few weeks now, but one of my question still hasn't an answer: are there optimal sequential comparison sorts for fixed-size – and random-access – ...
1
vote
2answers
419 views

Generating combinations algorithmically

Suppose I have an n-high pyramid of numbers like: 1 5 8 2 5 4 8 9 3 1 2 8 3 7 2 How can I algorithmically walk through every possible path from the top of the pyramid to the bottom? To ...
3
votes
2answers
90 views

Algorithm to identify degree of similarity based on prior categorization

I am working with digital images that people have manually categorized on a number of parameters. I want to be able to find images that are similar or dissimilar based on certain categories. For ...
1
vote
1answer
98 views

Algorithm for optimized variable generation without collisions?

I'm looking for an algorithm that can generate optimized syntactically valid variable names (for javascript in this case) without collisions. So as general rule I would want something that generated ...
3
votes
2answers
222 views

Big O Nested For Loop Breakdown

I understand how to get a general picture of the big O of a nested loop, but what would be the operations for each loop in a nested for loop? If we have: for(int i=0; i<n; i++) { for(int j=i+...
2
votes
1answer
240 views

How do you calculate affinity in Edge Rank/Activity Streams

I have been researching how to build a newsfeed that sorts the order by relevancy. I have been following along Facebook's Edge Rank and Etsy's Activity Feed Architecture and I can't figure out how ...
1
vote
1answer
161 views

Finite Element Shader

I am working on a geometric wrapper for a space jet exhaust impingement solver. A key part of the solution is determining what the jet can "see" and therefore hit. My model is grouped with nodes or ...
1
vote
0answers
49 views

Matching data based on multiple parameters and certain limits

I've been looking into the k-nearest neighbors algorithm as I might be developing an application that matches boxers in the near future. The reason my for question, is to figure out which would be ...
-2
votes
1answer
79 views

Computer Algorithms for Polynomial Regression [closed]

Given a data set of arbitrary size, what algorithm would be appropriate for performing the polynomial regression on the data set such that the highest degree of the polynomial is n? If there are ...
5
votes
1answer
159 views

Algorithm for predicting outcome based on parameters

I've never done anything with statistics, so I'm unsure of how to start with this problem that I need to solve for some software that I'm working on. Basically, there are three parameters An ...
1
vote
0answers
49 views

Recursive(?) algorithm design help

I have a requirement to allow my end users to input formula much like a spreadsheet. I have an array like this: $table = array( 1=>array( "id"=>1, "Name"=>"...