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
4answers
320 views

How to design a function that takes a date and gives out a number between 1-6, always the same for all dates

As a part of an algorithm I'm making I need to make a function that takes the current date to a function and gives out a number between 1-6, and not the same number for two consecutive dates. And it ...
-2
votes
1answer
160 views

Create arithmetic expression from number using +-/* that equals target [duplicate]

For example, you are given the source 1234 and the target 24. The task is to use the standard arithmetic operators +-/* placed within source, without changing the order of the digits of source to ...
5
votes
2answers
124 views

Find path of steepest descent along with path length in a matrix

Came across this problem -- You are given a grid with numbers that represent the elevation at a particular point. From each box in the grid you can go north, south, east, west - but only if the ...
0
votes
0answers
210 views

What is a lattice parser?

My friend asked me for help with his task: "Redeem a lattice parser with any programming language" - the problem is that he can't clearly explain me how the lattice parser should work. I've tried to ...
7
votes
2answers
304 views

Efficient algorithm to merge n successive sorted arrays in place

I am developing an in-place sorting algorithm that leaves the array into a state where it is basically a succession of sorted subsequences of any size (most are bigger than log2(size(array))); then it ...
0
votes
1answer
140 views

Do you know the name of this algorithm? (cycle with history?)

Context : I'm a IT student who is trying to implement a small application for my family. Every year, we offer each other gifts. Each one of us pick a name of a family member in a hat, and have to ...
1
vote
0answers
43 views

Graph grouping with criteria

I start with a list of adjacent tetrahedra, where there are tight seals to one another along faces for two tetrahedra that are adjacent. The vertices belonging to these faces for both tetrahedra are ...
4
votes
1answer
71 views

How to generalize the planar case of the closest pair problem to d dimensions?

I'm trying to create a solution for the Closest pair problem using d-dimensional points. I've done a thorough search on google but it seems that there is no explanation for the d-dimensional case ...
3
votes
4answers
512 views

Which algorithm is performant for matrix multiplication of 4x4 matrices of affine transformations

I am wondering what is a good, performant algorithm for matrix multiplication of 4x4 matrices. I am implementing some affine transformations and I am aware that there are several algorithms for ...
4
votes
1answer
126 views

Single Source Shortest Path

In the lecture we are taught that we can solve All Pairs Shortest Path(APSP) with matrix multiplication. In APSP we are creating a distance table for all the distances between each nodes in the ...
0
votes
0answers
70 views

Compute the permutations for a set of numbers and then run each to find every possible schedule that fits a client constraints

I am building a Java program that computes the permutations for a set of numbers and then runs each of those permutations to find every single possible schedule that fits a client constraints. The ...
2
votes
1answer
85 views

Algorithm for best subset of items

I have a matrix M with size NxN where each position M(i,j) is an integer representing the relationship between item i and j. If i and j are the same item then the positions M(i,j) and M(j,i) are 0. ...
-1
votes
3answers
139 views

Balanced folder increment

I want to map an integer (let's say 32bits) to a valid path. The integer is an autoincrement value stored in the database. I also don't want at any case any folder to have more than N subfolders. ...
3
votes
1answer
108 views

Finding xor sum in a tree

I was trying to solve this problem on hackerearth where you have a tree with values on each node and you have to answer queries that ask what is the xor sum between two nodes. Also, there are updates ...
9
votes
4answers
474 views

What is the most efficient way to store this data?

I am in charge of rewriting some old VB code. I understand how it works, but I feel like there is a far-more efficient way to do what they did. I just can't figure out what it is. Here is a contrived ...
0
votes
2answers
337 views

How to scramble a word, keeping first and last characters the same?

I have a task, which is to scramble a single word, whose size is greater than 3 letters. The scrambled word must not be equal to the original, and the first and last letters of the word must remain ...
14
votes
2answers
448 views

How to find hard to misspell given names?

Here is a question that I believe could be solved with some data mining and a sophisticated algorithm, but I don't quite know how. Any pointers as to what data sources to use and what algorithm to ...
1
vote
3answers
212 views

Data structure for sorting by multiple attributes

I have a list of integer pairs. The value of this list is the sum of the maximum values of each pair. For (0, 5) (20, 5) (6, 8) the value would be 5 + 20 + 8 = 33 Given a list like ...
6
votes
1answer
170 views

Identifying plagiarized jokes? [closed]

I'd like to be able to identify duplicate jokes posted on a website. I can build up a reasonably large database of previously-posted jokes, and then I'd like to look at each new joke as it comes in ...
5
votes
1answer
231 views

Combinatorial Optimization: Filling a Bag with Sand

I have an interesting "real-world" combinatorial optimization problem that I need to solve programmatically, however I have yet been able to whiteboard a good strategy. The task is similar to the ...
5
votes
1answer
76 views

Finding the smallest sub-collection of sets that intersect to produce one element

I came up with a problem that's similar to the Set Cover problem but which I can't reduce down to any know problem. Does anyone have a good algorithm for solving this? Given a set of elements U = {1, ...
-1
votes
1answer
100 views

Sorting an array based on another array's order, quickly [closed]

There are two arrays of maps. The first array contains maps of ID values in a specific order (but not necessarily either pure ASC or DESC ordering): // pseudo code first := [ {"id": 1}, ...
2
votes
1answer
86 views

Using a user defined equation to compute an entire list of numbers and store the list in an array

A example of what I want to do: User puts numbers into a list on a GUI that looks like this | L1 | L2 | l3 | ---------------- | 3 | 6 | | | 5 | 3 | | ... He writes in a text area ...
-1
votes
2answers
106 views

creating a social trend algorithm [closed]

I want to try to create an algorithm that would rank links according to social trends. I've article links, I've their date of publishing. I also have data from Facebook: comments, shares, likes. My ...
-2
votes
1answer
590 views

Bresenham Vs Midpoint Circle drawing algorithm

Can somebody explain the difference between Bresenham and Midpoint Circle drawing algorithms? All I am able to understand is that in both algorithms we compute coordinates of an octant instead of ...
3
votes
1answer
158 views

Burrows-Wheeler transform backward search: how to find suffix index?

BWT backward search algorithm is pretty straightforward if we only need the multiplicity of a pattern. However I also need to find the suffix indices (i.e. positions in the reference string where a ...
5
votes
3answers
313 views

Comparing two large strings to see how much they match [duplicate]

Is there an easy way of comparing any two different size of string text to see how much percentage they're alike? I'm trying this but I'm running into to this issue below. The left text area is the ...
-3
votes
1answer
82 views

complexity of an algorithm, sorting 5% out [duplicate]

I have been asked the following question.. An algorithm considers n elements, sorts 5% of n out, considers the remain elements(95%), sorts 5% of the remain elements, and so on until finally one last ...
0
votes
2answers
373 views

What is this algorithm?

I would like to implement an algorithm but I guess it's a well-known problem and it has been implemented yet, but I am unable to verify that without its name. Here is what I am willing to do : I ...
1
vote
1answer
91 views

MInimum tree coverage

I would like to understand what would be the optimal method of finding minimum tree coverage of tree nodes. Let me explain. I have a self-referencing structure that represents a tree, with a limited ...
-1
votes
2answers
87 views

Permuting and combining the values based on the key

I am trying to generate a table which would show all possible combinations based on the key. To make it more clear lets say I have a kind of Key, Value pair set(Its mentioned kind of because there are ...
0
votes
0answers
130 views

How does postback url works in campaign tracking systems?

my question is theoretical, a vague idea or some sort of algorithm will be great. I am building an advertising campaign tracker web app for a friend, yet i am kinda lost, i cant figure out how the ...
3
votes
3answers
118 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
272 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
213 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
219 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
89 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
245 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 ...
0
votes
0answers
74 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
93 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
119 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
431 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 ...
0
votes
2answers
98 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
40 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
98 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
83 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] ... ...
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
114 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
75 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 ...