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

Calculate which quantity packages to use based on quantity of bookings

In my app, many appointments can be booked for activities. Each activity has many price packages with a price and a quantity. On showing the cart, I need to work out what combination of packages ...
0
votes
1answer
139 views

How does stock brokers implement limit / trailing stop loss sell logic? [closed]

Let's take Fidelity for example, one can set to sell a stock with a trailing stop lost of 2% of last price, or even more simpler, one can set a limited sell order at any given price. And it must have ...
1
vote
2answers
165 views

How to measure algorithm accuracy?

I have a few optimization algorithms (for finding function minimum) and I'd like to check how good they are. Suppose I build test cases and compare the actual results to theoretical ones. What ...
1
vote
2answers
182 views

How to know whether to create a general system or to hack a solution

I'm new to coding , learning it since last year actually. One of my worst habits is the following: Often I'm trying to create a solution that is too big , too complex and doesn't achieve what needs ...
-1
votes
1answer
137 views

How to implement a genetic algorithm with distance, time, and cost [closed]

I want to make a solution to find the optimum route of school visit. For example, I want to visit 5 schools (A, B, C, D, E) in my city. Given the choice of five routes regarding what school I should ...
-1
votes
1answer
95 views

Finding “spare time” in a day from within a list of events

I have a list of events which is always sorted chronologically. The start time is always followed by the end time. Times are strings formatted as 'HHmmss'. // list of events var events = [ ...
7
votes
6answers
709 views

Algorithm to generate N random numbers between A and B which sum up to X

This problem seemed like something which should be solvable with but a few lines of code. Unfortunately, once I actually started to write the thing, I've realized it's not as simple as it sounds. ...
3
votes
2answers
165 views

Ranking players depending on decision making during a game

How would I go about a ranking system for players that play a game? Basically, looking at video games, players throughout the game make critical decisions that ultimately impact the end game result. ...
3
votes
2answers
145 views

How can I find the shortest path between two subgraphs of a larger graph?

I'm working with a weighted, undirected multigraph (loops not permitted; most node connections have multiplicity 1; a few node connections have multiplicity 2). I need to find the shortest path ...
1
vote
2answers
108 views

Looking for an algorithm to connect dots - shortest route

I have written a program to solve a special puzzle, but now I'm kind of stuck at the following problem: I have about 3200 points/nodes/dots. Each of these points is connected to a few other points ...
1
vote
1answer
119 views

Performing a Depth First Search iteratively using async/parallel processing?

Here is a method that does a DFS search and returns a list of all items given a top level item id. How could I modify this to take advantage of parallel processing? Currently, the call to get the sub ...
1
vote
2answers
70 views

Need to organize words based on their components, any other way aside from brute force?

I'm not sure if this process has a name. I have some words (about 9,000). They are in Japanese, but I'll try to explain this using English words. I want to categorize the words by the components (in ...
-1
votes
2answers
77 views

Can this word search algorithm be made faster? [closed]

Problem: Find a match of word S in text T Given: S and T are part of spoken and written English. Example: Match 'Math' in 'I love Mathematics' NOTE: Ignore CASES. My algorithm: STEP 1) Convert S, ...
1
vote
3answers
221 views

Finding the shortest path through a digraph that visits all nodes

I am trying to find the shortest possible path that visits every node through a graph (a node may be visited more than once, the solution may pick any node as the starting node.). The graph is ...
0
votes
0answers
72 views

Approach for packing 2D shapes while minimizing total enclosing area

Not sure on my tags for this question, but in short .... I need to solve a problem of packing industrial parts into crates while minimizing total containing area. These parts are motors, or pumps, ...
0
votes
2answers
113 views

How to avoid or minimise use of check/conditional statement in my scenario?

I have scenario, where I got stream and I need to check for some value. If I got any new value I have to store it in any of data structure. It seems very easy, I can place conditional statement ...
1
vote
2answers
44 views

Algorithm to match items be value into sets base on total

Given n sets of items. Each item has a value. The items in a set have similar values but vary by a small amount. The goal is to create new sets containing three items selected from the original sets ...
7
votes
2answers
1k views

single for-loop runtime explanation problem

I am analyzing some running times of different for-loops, and as I'm getting more knowledge, I'm curious to understand this problem which I have still yet to find out. I have this exercise called "How ...
2
votes
1answer
145 views

Asymptotic running time of for-loops

I have this question which I need answered: What is the asymptotic running time for the following piece of code? if (N < 1000) for (int i = 0; i < N; i++) for (int j = 0; j < N; ...
-2
votes
2answers
57 views

Know executables files launched/loaded by an executable file [closed]

I would like to know any executable files launched or loaded by an executable file (if possible without running it,if it is not possible i don't want any change in the system). For example i have ...
0
votes
2answers
325 views

Running time of simple for-loops

I'm reading algorithms and I understand most of it, one thing that I can still struggle with a lot is something as simple as running times on different for-loops. Everyone seems to have easy with ...
1
vote
1answer
100 views

City exploration algorithm

The purpose of the algorithm is to create n routes on a geographical map, where n is being given, whereas all routes take no longer than t time units by foot and end where they start, while trying to ...
0
votes
1answer
140 views

Dual pivot quicksort in face of expensive swaps

I was told this is better place to ask this TLDR Has anyone tested dual pivot quicksort performance with expensive-to-swap elements? It seems that in this case, it should massively underperform ...
4
votes
1answer
104 views

JS design pattern/algorithm for avoiding duplicate redraws in a fairly coupled system

Given: some sort of widget based web app lots of JS functionality high coupling (communication/callbacks between widgets) widgets draw themselves certain widgets need to do a complete and fairly ...
-4
votes
1answer
163 views

Calculate Pi to N number of places [closed]

I am trying to work out how to calculate Pi to N decimal places, I think the default DP's for a float/double is 5 and then you have setprecision() however these are obviously inadequate, I need ...
1
vote
2answers
199 views

Level order sorted binary tree from a binary tree

Lets suppose we have a binary tree . Tree node structure is as struct node { int val ; struct node *left , *right ; } Now we have to sort the tree in level order manner . For example lets ...
0
votes
1answer
62 views

How to chain together points in an array

I have a series of points with lengths and rotations like this: I need to create separate chains from points whose lines overlap but I’m having real trouble doing this efficiently. I have an array ...
1
vote
1answer
84 views

Confusion in understanding the theorem on Amortization

I was reading a book on Algorithm Analysis by Micheal T Goodrich. I came across amortization technique and I got struck in understanding the proof of theorem. I am putting the theorem and the proof ...
1
vote
2answers
190 views

Best practices for geolocation

We are writing a flight search engine. We want to pre-fill the departure airport for mobile users with the closest one to their location. To do that, our plan is to Find a list of airports with ...
1
vote
1answer
61 views

Find common ancestor

Given X number of leaves (the ringed leaves in the picture) in an unbalanced tree with depth aroun 100-1000 and total number of nodes around 15 000 000. I'm looking for the first common ancestor for ...
1
vote
2answers
70 views

Creating fast, realtime dialogue search for television scripts

We have a database of television scripts and we'd like to search it, getting results as we type. We often remember words or snippets of dialogue but can't remember exactly what was said or what ...
4
votes
2answers
76 views

Distribute load evenly across many cycles

I am looking for a solution that is fast and still readable. I have to do this in C but the code will be static in the end, which mean I could use any tool to generate it. I have a task which runs ...
0
votes
3answers
106 views

How to convert this recursive problem to iterative? Line Simplification algorithm fails to run due to Maximum Recursion Depth being hit

I am implementing the Douglas, Peucker's Line Simplification algorithm in Python. I started with this implementation. However, it fails to run in Python due to Maximum Recursion Depth being hit. How ...
0
votes
0answers
42 views

Stable, Hash Based Symmetrical Difference

A lot of thought went into the implementation of the set algorithms in LINQ: Distinct, Except, Intersect and Union. They guarantee that the items are returned in the same order that they appear in ...
1
vote
1answer
88 views

Notation/Meta Language To Express An Algorithm

I need to learn a notational language, so I can express and possibly prove the correctness of what I believe to be a complicated algorithm that distributes a credit adjustment across multiple water ...
0
votes
2answers
130 views

Permutation tests for large sequences

I would like to perform a permutation test on a particularly large data set, i.e. around 4 million entries. Basically, I need to get some number of random permutations of this data set. Usual way to ...
4
votes
1answer
83 views

How to define the motion path of one object on a surface of the other one?

I have an uncommon problem. There are 2 3D objects, which are represented by arrays of vertices and triangles (.stl files). Each of them contains a big enough amount of vertices: 1-10 mln ones. The ...
0
votes
1answer
129 views

Programming a promotions engine [closed]

I am trying to implement a promotions engine for an e-commerce application and I want to figure out how such engines work especially in situations like the following. Buy X Items from Category A ...
1
vote
2answers
142 views

Sequentially/parallel algorithm for extracting blob outer perimeter/contour length

I have labelled the connected components in a binary image and found their areas and bounding boxes. The components are not necessarily filled, and may contain holes. I wish to identify the component ...
8
votes
1answer
1k views

I know JavaScript really well, but i bomb coding interviews [closed]

So I'm currently on a hunt for a new position as a Front-End Developer. I know JavaScript very well and can wax poetically about Closures, Currying, Prototypal Inheritance, Design Patterns, App ...
3
votes
2answers
80 views

An algorithm for finding subset matching criteria?

I recently came up with a problem which I would like to share some thoughts about with someone on this forum. This relates to finding a subset. In reality it is more complicated, but I tried to ...
-2
votes
2answers
256 views

Which algorithm is faster? [closed]

I'm creating a small game, where the computer generate pseudo random number in give range, and the user have to guess it. I also made the option to play computer vs computer. I mean the computer ...
1
vote
2answers
87 views

Algorithm to reverse engineer permutation [closed]

I have a sequence of permutations formed using these strings: "A", "BC" and "D". The permutations are: BCAD ABCD BCDA DABC ADBC DBCA Now I need to reverse engineer this; i.e. I have a text file ...
3
votes
1answer
164 views

How to create an algorithm for determining Boolean Tautologies

So i am right now exploring some topics in a proof course and it occurred to me to try to create a boolean tautology solver. I would like an algorithm that is more efficient than brute force. Problem ...
1
vote
0answers
107 views

Dynamic programming in Bin packing

Problem: Given a list L of objects of possible sizes from set S={1,2,4,8} and unlimited supply of bins of sizes 16 each and we have to use minimum possible numbers of bins to pack all objects of L. I ...
10
votes
5answers
706 views

Print the next smallest from 2^i * 5^j where i,j >= 0

I was asked this question during a technical phone screening recently and didn't do well. The question is included verbatim below. Generate {2^i * 5^j | i,j >= 0} sorted collection. ...
1
vote
2answers
162 views

What's the shortest generating one-way hash algorithm?

I have a 24 character long id which is guaranteed to be unique. I would like to shorten that to 7-10 (or even shorter) characters long. If I generate an short id randomly then I would have to check ...
1
vote
1answer
148 views

Algorithm for rating books: Relative perception

So I am developing this application for rating books (think like IMDB for books) using relational database. Problem statement : Let's say book "A" deserves 8.5 in absolute sense. In case if A is ...
0
votes
0answers
121 views

Dividing 2D grid to most efficient search

Requirements I have Grid of unlimited size (I don't and can't know what its size) There is Object that should be placed on the grid, every object have hes stream distance (in other words: range, ...
1
vote
1answer
90 views

Ensuring submitted hiscores are not fake

I have a small game that I would like to keep track og global hiscores for. The basic is simple: username and score is submitted to a server for storage and later polling. However how do I ensure that ...