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)

-2
votes
3answers
70 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" ...
-3
votes
0answers
14 views

write a MATLAB code to sketch 2D electric field vector

Write a MATLAB code to visualize (2D) the electric field vector due to finite line charge of length 𝒍, placed in free space. The code must ask the user to input the value of the charge density 𝝆𝒍 ...
0
votes
1answer
47 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 ...
0
votes
1answer
47 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) ...
2
votes
1answer
45 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
146 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
62 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
357 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
0answers
64 views

How can I oprimize this hash table in C? [on hold]

I want to run greedy algorithm to coloring vertex. A vertex is an unsigned int of 32 bit. And the hash table represents the important part of the graph. I must holds like 1 000 000 vertexes and edges, ...
5
votes
5answers
256 views

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

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
141 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, ...
3
votes
1answer
86 views

Find minimum number of steps to a goal without estimator for how close intermediate steps are to the goal

I've been trying to find a good way of solving the following problem, but I'm not sure how to even frame it. I think there might be relatively well-known solutions I'm not familiar with, since I don't ...
-4
votes
1answer
72 views

Generate this kind of 2d burst or pulse algorithm?

I'm currently trying to develop a game using Cocos2d-x using C++ I really need to generate this burst or (donut-shaped) pulse. I'm having a difficult time how to generate such shape. At first, I was ...
2
votes
1answer
267 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
175 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
299 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
204 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
371 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 ...
12
votes
3answers
1k views

What is O(…) and how do I calculate it?

Help! I have a question where I need to analyze the Big-O of an algorithm or some code. I am unsure exactly what Big-O is or how it relates to Big-Theta or other means of analyzing an algorithm's ...
0
votes
2answers
235 views

How to approach hours forecasting

I need to forecast budgeted hours for 2 departments to help them schedule staff as currently the best they can do is just wing it. When we receive a job proposal I'll have the person submitting the ...
1
vote
1answer
91 views

Algorithm to create all unique sets of the alphabet using arbitrary group sizes

I'm looking for an algorithm to help me out with a combination of combinations problem. I have generated two lists of combinations of letters: (26 choose 6) & (26 choose 5) My goal is to be able ...
4
votes
1answer
123 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
0answers
67 views

find the longest word made of other words

I am working on a problem, which is to write a program to find the longest word made of other words in a list of words. I post two versions of code, and wondering if IsComposite2 is more functionally ...
0
votes
2answers
72 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
38 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
451 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
23 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
66 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 ...
16
votes
6answers
40k 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 ...
832
votes
10answers
302k 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 ...
6
votes
1answer
91 views

Fuzzy algorithm for grouping data

I have data that indicates which topics each student has got right/wrong in an assessment.: | Student | Topic 1 | Topic 2 | Topic 3 | Topic 4 | Topic 5 | ... (perhaps 30 topics) | 1 | T | ...
1
vote
2answers
131 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
267 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
55 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
50 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
65 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
168 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
199 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 ...
3
votes
1answer
128 views

Dynamic Programming - Largest arrangement of bookcases

I'm trying to solve a problem, so I'm not looking for code, but for similar algorithms so I can solve it myself. I am given n bookcases each with a size amount of books inside. I am to move some of ...
0
votes
0answers
47 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
340 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 ...
1
vote
1answer
74 views

How to “de-dupe” similar lines (detected using the Hough Transform as rho/theta pairs)

I'm trying to identify an object (a cube) in a set of photos. Using Canny/Sobel/Hough I've managed to get the photo down to a set of lines that are pretty accurate; however if I plot these lines on my ...
0
votes
1answer
97 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
76 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
462 views

Grouping algorithm

We've developed an algorithm that depending on the check-in time of some workers and their living place, calculates the way to group them into some vehicles and the route which must be followed by the ...
5
votes
2answers
284 views

Automatic Appointment Conflict Resolution

I'm trying to figure out an algorithm for resolving appointment times. I currently have a naive algorithm that pushes down conflicting appointments repeatedly, until there are no more appointments. ...
2
votes
1answer
134 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
158 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 ...