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)

6
votes
1answer
80 views

Data structure for determining intersection between line and polygon in 3D

I have a collection of non-self-overlapping simple polygons P. In actuality, they are 2D triangles in 3D-space. I'm looking for a data structure which, given a line L, has a relatively fast lookup ...
-2
votes
0answers
26 views

UITableView addition SWIFT

I have a UITableView that lists items. Each item has a quantity and a price. The information is saved in the CoreData and I need to get the total of all items I managed to get the total only for each ...
1
vote
1answer
47 views

Implementing CMA-ES

I am attempting to implement the CMA-ES optimization algorithm in my favorite language (using the example code here as a guideline), but I need help solving a problem I am having. To test the ...
-2
votes
3answers
120 views

How to create an algorithm for a raffle, where each raffle guarantees a winning ticket?

I am looking for an algorithm to create a raffle, where each participant is assigned a ticket with a random series of numbers. Each raffle hast N participants, and there should exist same amount of ...
2
votes
1answer
168 views

Getting started with machine learning a zero sum game?

I have a simple zero sum, discrete, deterministic, complete information board game. I want to machine learn an evaluation function for an AI agent. Suppose each board state has ~20 identifiable ...
0
votes
1answer
50 views

Creating hyperlinks in documents and messages

In Sweden the abbreviation "t.ex." means "for example" ("till exempel") and it is extremely common. Every time I write that t.ex. in an email or in a text message it gets marked up as a clickable ...
2
votes
2answers
162 views

Poker split / side pots

I am writing a poker application and trying to figure out how to deal with split pots and side pots There are four rounds of betting and each round of betting can have multiple orbits Can only ...
1
vote
0answers
58 views

Resource Allocation Algorithm

I have a question about assigning values to nodes laid out in a physical space: There is a set of N fixed nodes spread out throughout a certain 2 dimensional region that need to be assigned a value ...
2
votes
1answer
242 views

Word game algorithm

Back in the days of 8-bit machines there existed an educational word game. I have no idea what it was actually called but for the sake of this question (since it involves pyramids) let's call it ...
0
votes
1answer
62 views

Alert when size of continuous stream of events exceeds 1000

A friend of mine was recently asked this question in an interview. Lets say there is a continuous stream of incoming events E1, E2 each with timestamp of entry associated with them. Write a java ...
0
votes
4answers
181 views

a funky interleaved sorting problem

I have an array of items. Some items have a number on both sides. I'll call these "matched pairs". I need to sort the items between the matched pairs in a particular way. There's a "from number" ...
5
votes
6answers
437 views

Algorithm for determining transactions among weekly data series?

I'm trying to develop a small reporting tool (with sqlite backend). I can best describe this tool as a "transaction" ledger. What I'm trying to do is keep track of "transactions" from weekly data ...
0
votes
1answer
52 views

Mapping match-up combinations into an integer

First of all, I want to say I wasn't sure if I should post this here or in math.stackexchange but I think the question is too programming-related to belong to the latter community. Definetly not a SO ...
1
vote
1answer
54 views

How to improve timeout value dynamically?

I'm working on an application where I want to keep a timeout value computed dynamically using a moving average of say 100 previous response times for service A. This value + some buffer (~3 seconds) ...
4
votes
1answer
55 views

Efficient Value-Lookup in List of k-Tuples

I've encountered a problem in a personal project that I think could be solved by a particular data structure but I'm not sure what. The problem is as follows: Given a set of k-tuples, provide an ...
0
votes
1answer
147 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
1answer
71 views

Yen's k shortest paths algorithm

I'm currently trying to understand Yen's k shortest paths algorithm. I based myself on the original paper as well as on the Wikipedia article, but still cannot see why it is correct if k > 2. In fact, ...
1
vote
1answer
360 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 ...
5
votes
5answers
265 views

My brute force solution is too slow, needed DP solution [closed]

Concise problem definition: given n and {a,b,c}; (1 ≤ n, a, b, c ≤ 4000); Constraint -> a*i + b*j + c*k==n (i,j,k>=0); Objective-> maximize(i,j,k) Examples: n=47 and a=7,b=5,c=8 -> ...
-1
votes
4answers
155 views

What algorithm would have the fastest average run time and least memory requirements for sorting a deck of playing cards?

Considering a deck of N playing cards with X different rankings and Y different suits (i.e. there are Y cards with X ranking, thus N=X*Y). What is the fastest algorithm to sort them assuming that X, ...
2
votes
1answer
270 views

What should I call this utility function? Is something like it commonly used?

Suppose you want to combine some arrays of objects that have similar properties: var people = [{name: 'Jack', age: 10}, {name: 'Jill', age: 12}] var items = [{owner: 'Jack', name: 'pail'}, {owner: ...
2
votes
3answers
193 views

Binary Search Tree without Natural Ordering

This is kind of a multi-part question. Is it possible to do a binary search tree if the data does not possess natural ordering? Would you be forced to impose artificial ordering to such data? Like ...
0
votes
1answer
309 views

One font OCR for meme images

I'm coding an Optical Character Recognition specifically for the Internet meme images. This is a school project and it should be coded in C. I'm currently having trouble with the method/algorithms I ...
0
votes
1answer
210 views

My algorithm is too slow

Reposted from Stack Overflow - I think this is a more appropriate place to ask the question. I have an algorithm that for an integer x and a starting integer i such that 1 < i < x the next ...
1
vote
3answers
389 views

Big O notation of randomness

I was thinking about inefficient algorithms based on randomness and wondered how to categorise them. For instance. Say you wanted to generate all the numbers from 1 to N in a random order but only ...
4
votes
1answer
136 views

Word ladder efficency problem

I have a problem dealing with word ladders. The problem is: given two words and a dictionary file, find the shortest word ladder between the two words. So if given the words cat and pot: cat -> ...
0
votes
2answers
75 views

Ordering 'Tasks' for execution based on their dependencies

Let's say I have a set of Tasks that they have dependencies. These tasks are not in order, but the execution of tasks should be in the proper order. Each task has two properties: Before and After. ...
1
vote
0answers
43 views

Filtering algorithm for word game

Suppose you have a number of anagrams for the same letters, for example: alerting altering integral relating triangle Suppose you have a game where you must find all the anagrams, by placing letters ...
2
votes
4answers
490 views

What is Big-O notation for purely functional languages?

Is it still relevant? Instead of var result = new List<int>(); for (var i = 0; i < prev.Count; ++i) { result.Add(prev[i] * 2); } where the result.Add, prev[i], and * 2 instructions ...
0
votes
0answers
29 views

How would I identify a gap in a set of curve data, and get its value?

I have a set of 2-D data (x,y) and it produces a set of curves, and sometimes the set of curves do not overlap, and there is a distinct separation between the groups of curves, how would I identify ...
4
votes
0answers
70 views

Modelling a complex schedule of work

I've got a real-world problem that I'm trying to represent and automate. I've simplified and abstracted it down to the following: There are n places of work (P1, P2, ..., Pn). Each place, Pn has a ...
17
votes
6answers
42k views

How to quickly search through a very large list of strings / records on a database

I have the following problem: I have a database containing more than 2 million records. Each record has a string field X and I want to display a list of records for which field X contains a certain ...
841
votes
10answers
308k views

Which hashing algorithm is best for uniqueness and speed?

Which hashing algorithm is best for uniqueness and speed? Example (good) uses include hash dictionaries. I know there are things like SHA-256 and such, but these algorithms are designed to be ...
1
vote
2answers
146 views

Binary Search O(log(n)) or O(n)

I see where most readings online derive that the Big-Oh notation of a Binary Search is O(log(n)), but doesn't this assume a balanced tree? What if the tree is completely unbalanced (i.e. similar to a ...
0
votes
3answers
269 views

Big-O notation for other cases

I was just reading answers to a question Plain English explanation of Big O From that i came to know that Big-O notation is just an "upper bound" of the complexity of an algorithm? But can we apply ...
1
vote
0answers
56 views

Implementing an algorithm for parallel task scheduling

Problem Given a set of applications "A[]" with execution cost "Ex" ,Arrival Time "t", Resource requirements "R" and the system having free resources "Fr", calculate the finishing time of all of the ...
1
vote
1answer
78 views

Clairvoyance in caching - optimal strategies?

This question relates to the question here, but I'll generalise it so that you can answer effectively without reading all of that. Context: Imagine you had a large set of data greater than your ...
1
vote
2answers
53 views

Place X items in N matrices without repeat column and row

I have N matrices (n × m) and items to place in each one (n · m). The same items are repeated randomly for each matrix. When one item is placed in (i, j), for the following matrices the ...
2
votes
1answer
67 views

Caching in '3D' - data-structures and octree recursion - hrrm!

The Situation: I have 68GB of data that is conceptually realized as a 3D matrix of 8-bit values with dimension 4096*4096*4096. I need to access multiple sections of this data for processing in a ...
5
votes
2answers
178 views

Best compression algorithm for timelapse photos

I have a folder containing about 9,000 JPEG photos (about 30Gb), which I want to archive with some sort of compression. I understand that compressing JPEGs is not normally very effective, but these ...
0
votes
3answers
214 views

Algorithm to determine the fastest route passing in all points

Given a starting point A and an end point E, I need an algorithm to determine the minimum transit route in a city that passes through all points (A, B, C, D, E) and is the fastest possible. I know I ...
0
votes
0answers
52 views

Algorithm and time-complexity of creating a sports schedule

With the NFL schedule being released last night, I started thinking. How would one automate the process of creating a schedule for a league such as the NFL? Even if we ignore all the challenges of a ...
4
votes
3answers
346 views

Work out which parcel deliveries we ship ourselves and which we outsource

Firstly, I hope I'm asking this in the right place. I work for a large online retailer in UK. We ship approaching 2000 orders each day and are growing very quickly. We currently use multiple delivery ...
0
votes
1answer
99 views

Calculating variable distances

I'm attempting to write an algorithm that calculates the distance between vertebrae. The text parser already works perfectly in picking out vertebral references (cervical 6, c-6, c6, c six, cervical ...
0
votes
5answers
1k views

Algorithm for recursive evaluation of postfix expressions

I'm reading Sedgewick's book on algorithms in C and I'm looking for an algorithm to evaluate postfix expressions (addition and multiplication only) without using a stack. I tried to implement one but ...
1
vote
1answer
80 views

Most efficient way to keep count of objects in State X without constantly counting

The application I work on manages hundreds of thousands of records each in a different state in their lifecycle. A large requirement is to have a nearly accurate count of these objects in each state ...
2
votes
1answer
156 views

Sudoku Solver BackTracking vs Simulated Annealing

Before you read any further, assume you know what sudoku game and how to go about solving it. So I have created a sudoku solver with brute-force: The algorithm goes as calculate(through an simple ...
2
votes
0answers
185 views

Find all paths in a tree type of structure

The language I am using is C#, but I am looking more for help with the algorithm more than I am concerned with which language. I have been trying to develop this algorithm for a while now and I can't ...
0
votes
0answers
38 views

Algorithm for rate-limiting uploads with 3 files max

I want to limit file upload frequency to our webservice to prevent denial-of-service (directed at the server) - specifically, temporary folders filling up with fake uploads. This could be the user ...
2
votes
2answers
73 views

Algorithm for implementing QOS in my proxy

Here's the situation: I'm making a proxy (for the moment running on my laptop) which deals with HTTP(S) requests from incoming clients (for the moment only one client, i.e. my Chrome browser on my ...