# Tagged Questions

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.

144 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. ...
123 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 ...
510 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 ...
388 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 ...
531 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 ...
259 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 this,...
173 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 ...
240 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 ...
97 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, ...
105 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}, {"...
91 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 ...
111 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 ...
793 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 ...
177 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 ...
444 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 ...
83 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 ...
376 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 ...
98 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 ...
110 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 ...
185 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 ...
128 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 ...
309 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 ...
223 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 ...
222 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 ...
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 ...
250 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-...
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 ...
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 ...
124 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 ...
570 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,......
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 ...
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 ...
111 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 ...
93 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,...
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 ...
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 ...
117 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 . ...
93 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 ...
129 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: ...
100 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 ...
284 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? ...
188 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 ...
77 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 ...
112 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 ...
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 ...
207 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 ...
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 ...
75 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 + ...