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
0answers
15 views

Sequence Alignment: How to use the score table?

So I have this task to implement an dynamic programming algorithm solution that computes the score and the proper alignment for some sequences. For example, the following sequences: Toy_FASTAs.in ...
-1
votes
0answers
20 views

Tournament Scheduling Algorithm Starting Point

This is a question about performance and best placement of matchups within a schedule that contains dates/times/locations. Starting with a schedule grid (date/time/locations) in place and all ...
0
votes
0answers
107 views

how to use Sql query to search text in CSV file and avoid iteration

I have one A File and many input files ,All files have CSV format . I want to match text of one column of all input files with one of the column of A file . I have stored all column value of File A in ...
0
votes
1answer
67 views

How are the tiles in WORDAMENT organized?

I'm trying to create a word game, just like WORDAMENT, in my spare time. In order to present a new round, I need to create a board with 16 letters organized in a 4*4 grid. Currently, I'm generating ...
0
votes
0answers
47 views

Floating point number to binary

Which Algorithm does java uses to convert floating point number (Ex:0.15625) into binary(0.00101). Whether java uses normalized form or denormalized format ? If i type "float ab=0.15625" in java ...
2
votes
3answers
138 views

Find all possible subarrays of an Array

I am lost I just can't seem to get my head around backtracking/recursion approaches. I understand how simple recursion problems like factorials work I can even trace those by hand. But when it comes ...
2
votes
1answer
47 views

Need help identifying a league scheduling algorithm

I am trying to create a sports league scheduler. I am having trouble identifying an algorithm to help me efficiently fill in each slot. Sample data to build the schedule would be: 10 teams Each ...
-3
votes
0answers
37 views

Dynamic programming algorithm for finding minimum spanning tree [on hold]

I know cool greedy algorithm like brokuva, kruskal and prim's exists for finding minimum spanning tree but I am curious to know a dynamic programming algorithm for finding minimum spanning tree.I am ...
-4
votes
1answer
86 views

Does the head of any linked list must contain any data [closed]

Is there any rule that says the head of any linked list should contain data. Is it because by doing it so we save a space for one node. Why for some implementation of head contains data and for other ...
-1
votes
1answer
91 views

Unevenly distributed random number generation [duplicate]

Let's say I have to generate random number from 1 to 100, however, the probability of each number is not 1/100, but a predefined probability. How to generate that number? I use Ruby/Python.
4
votes
2answers
149 views

algorithmic problem - Combining overlapping ranges

I'm looking for an idea to efficiently solve following problem: I have a set of pairs of ranges (range = a pair of numbers), each range is unique (but has same size) e.g. [ [(0,6),(34,40)], ...
1
vote
4answers
116 views

Efficient “Object with weights” structure

I need to find an "efficient" data structure / set of algorithms to do the following things: I have a list of objects. I need to assign them weights and later on increase or decrease these weights. ...
4
votes
2answers
92 views

To find the oldest/newest element in a heap

I want to find the oldest/newest element added into a heap of size k. At any given point of time if I have to find say the oldest element in the heap is there any approach with O(1) space and O(1) ...
0
votes
3answers
193 views

What does this function do?

Does this function means its calculating x=(x-1) + x^2? Function unknown(x) if ( x == 1 ) return 1 else return unknown(x‐1) + x*x
0
votes
0answers
67 views

What Algorithm can be use for task allocation based on location?

What algorithm can be use for task scheduling based on location? For example there are 100 students and 5 lecturers available. Each lecturer must get same amount of student using location allocation ...
0
votes
1answer
64 views

Count Sort Algorithm efficiency

As I am reading a Book about "Algorithm Analysis", I came across count_sort Algorithm. A question has been raised in my head. I read in many other papers, that "Quick Sort/ Merge Sort" are the best ...
0
votes
1answer
34 views

Tweaking a ranking algorithm from a few variables

I'm going to have a mySQL table with elements in it and would like to rank them in the same manner than Reddit but not quite. I'd like to know how to add or remove importance to a variable in my ...
2
votes
1answer
36 views

I have an unordered list of rectangles and their neighbors on four sides with no origin. How can I efficiently convert this into a grid?

I am writing a GtkGrid-like container for my GUI library for Go, and I'm trying to write the actual layout part of the code. Basically, I have an unordered list of controls. Each control is a ...
6
votes
3answers
253 views

Algorithms for making image mosaics - is there a quicker way than this?

I've been playing with making image mosaics. My script takes a large number of images, scales them down to thumbnail size and then uses them as tiles to approximate a target image. The approach is ...
1
vote
4answers
115 views

Is there a clever way to calculate a mode of an online series without storing the series?

My program's aim is to determine the correct time zone offset (GMT+k) as a series of numbers are fed to it. eg: -4 +11 1 -4 -4 So, here -4 (the mode of the series) is the correct value. But this ...
0
votes
1answer
45 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
0answers
7 views

In Perl, best way to insert a char every N chars [migrated]

I would like to find the best way in Perl to insert a char every N chars in a string. Suppose I have the following : my $str = 'ABCDEFGH'; I would like to insert a space every two chars, so that I ...
0
votes
1answer
119 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
158 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
167 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
104 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 ...
0
votes
1answer
83 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
547 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
151 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
111 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
67 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
80 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
68 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
75 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
90 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
51 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
108 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
42 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
114 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
51 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
162 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
95 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
59 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
87 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
111 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
130 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
61 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
75 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
128 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 ...