An algorithm is a sequence of well-defined steps that defines an abstract solution to a problem. Use this tag when your issue is related to algorithm design.

learn more… | top users | synonyms (2)

0
votes
0answers
6 views

Algorithm: How to re-arrange a time-range event list based on wether time events overlap, faster than O(n^2)?

Let's say I have an array of time ranges like so: [ { name: 'A', startTime: '10:15', endTime: '11:15'}, { name: 'B', startTime: '10:45', endTime: '14:15'}, { name: 'C', startTime: '15:35', ...
7
votes
5answers
4k views

Maximum subset which has no sum of two divisible by K

I am given the set {1, 2, 3, ... ,N}. I have to find the maximum size of a subset of the given set so that the sum of any 2 numbers from the subset is not divisible by a given number K. N and K can be ...
0
votes
1answer
14 views

Adding pattern to SeedFill algorithm

I am implementing a seedfill algorithm. For the color I use generic variable. However I don't know how to implement the pattern patt which is integer. Here is the source code: public class ...
-2
votes
0answers
19 views

finding the kth smallest element in 3 sorted arrays of size n

suppose we are given three sorted arrays A[1 .. n], B[1 .. n], and C[1 .. n], and an integer k. Describe an algorithm to find the kth smallest element in A U B U C in O(log n) time. Thanks for the ...
0
votes
2answers
29 views

A pseudocode algorithm for integer addition based on binary operation

I have tried for ages to come up with a solution but just can't get my head around it. It needs to be based on two integers on the use of standard logical operations which have direct hardware ...
-1
votes
1answer
9 views

SNP (Single nucleotide polymorphism)

I need some tools(run on windows) used for SNP detection . i used this http://archive.broadinstitute.org/mpg/snap/ldsearch.php but with no help. Thanks.
15
votes
2answers
5k views

Algorithm or library for color quantization/reduced image color palette in Javascript? [on hold]

I'm writing a web app that takes a user-submitted image, gets the pixel data via a canvas element, does some processing, and then renders the image using vector shapes (using Protovis). It's working ...
0
votes
2answers
24 views

Get a sequence bits from a unsigned long c

I am wondering if anyone can help me I am just learning c and I apologize in advance if I am using the incorrect terms. I am trying to implement a an algorithm but I am having a problem at one ...
44
votes
11answers
11k views

Algorithm challenge: Generate color scheme from an image

Background So, I'm working on a fresh iteration of a web app. And, we've found that our users are obsessed with being lazy. Really lazy. In fact, the more work we do for them, the more they love ...
1
vote
1answer
47 views

A* pathfinding - Slow with huge open maps

I've implemented A* pathfinding which works flawlessly for smaller grids. However, when the maps become large and no longer maze-structured, such as the map pictured below, the algorithm becomes ...
2
votes
0answers
22 views

How can I implement the Viterbi algorithm in C# to split conjoined words?

TLDR : I want to convert the first answer to the question here from Python into C#. Background I wish to convert conjoined strings such as "wickedweather" into separate words, for example "wicked ...
1
vote
1answer
27 views

Algorithm for adding two integers based on the use of standard logical operations like AND, OR, XOR, NOT

Algorithm for adding two integers based on the use of standard logical operations like AND, OR, XOR, NOT Does anyone know an algorithm for this? I can't seem to find one that works as I am very new ...
14
votes
4answers
14k views

PHP algorithm to generate all combinations of a specific size from a single set

I am trying to deduce an algorithm which generates all possible combinations of a specific size something like a function which accepts an array of chars and size as its parameter and return an array ...
0
votes
1answer
31 views

How to handle processing of large file on GAE?

I'm looking for a powerful and fast way to handle processing of large file in Google App Engine. It works as the following (simplified workflow at the end): The customer send a CSV file, that our ...
0
votes
0answers
9 views

What is the condition to stop splitting data in Non-Uniform Quantizer?

I'm trying to implement a non-uniform quantizer with N-level of quantization. I have already done some work and it works, the problem is it goes into infinite loop when N(the number of levels) exceeds ...
1
vote
3answers
32 views

Already nearly sorted array

Hello everybody I would like to ask for your opinion. What algorithm would you advice for sorting arrays A with most four numbers that are in wrong place and obtain an efficient asymptotic running ...
-3
votes
0answers
13 views

Longest possible string from given characters and set of strings

How to solve? Given an array of strings and characters, make the largest possible string. The resultant string should be a combination of the strings given in the array B. The frequency of every ...
-4
votes
0answers
20 views

Approach to solve a codeforce algorithmic [on hold]

Given an odd integer N, for every N print the following shape: (N is always odd) Examples: for N = 3 print: * * *** * * for N = 5 print: * * ** ** ***** ** ** * * for N = 7 print: * * ...
2
votes
2answers
24 views

RK4 - Runge-Kutta Algorithm for ODEs of a single variable

Sorry in advance if this is a simple/stupid question. Every explanation of RK4 that I've seen uses a function of two variables; eg. f' = f(u, t) with initial conditions t0 and u0=u(t0) and a step ...
0
votes
0answers
30 views

SK learn, Python

I want to make a regression that is determined by the operator XOR. I created a training set: Then I created a test set: I use this code: import numpy as np from sklearn import metrics from sklearn....
4
votes
3answers
197 views
+200

Efficiently merging and re-sorting sorted lists

This isn't the classic "merging two sorted" lists questions, which is fairly trivial to do in linear time. What I'm trying to do is merge two lists, already sorted, which contain common objects which ...
1
vote
3answers
26 views

Fast set overlap matching algorithm

Let's say I have two sets: A = [1, 3, 5, 7, 9, 11] and B = [1, 3, 9, 11, 12, 13, 14] Both sets can be of arbitrary (and differing numbers of elements). I am writing a performance critical ...
0
votes
1answer
34 views

Error on Arithmetic Coding Compression Algorithm

I am trying to implement arithmetic coding which is a compression algorithm. Here is the compression code.When I compiled it Exception in thread "main" java.lang.RuntimeException: Uncompilable ...
1
vote
0answers
15 views

Partitioning with constraints of edge weighted graph

I have an edge weighted connected graph. It is not a directed one. My task is to remove a few edges so that the graph become divided into at least two half and the sum of weights of the removed edges ...
-1
votes
1answer
40 views

Unexpected behaviour of Merge Sort algorithm in Java

I have tested the merge method and it is working fine for all the cases but somehow the mergeSort method is not producing the correct output, it simply divides the array into smaller sub arrays and ...
-6
votes
0answers
22 views

Algorithm of operation over array in c++ [on hold]

Who can write algorithm (computer simulation) of search , delete, insert and update operation of array? For c++
0
votes
0answers
30 views

Consolidate multiple table in one unique table

I have 5 tables. Each table contains a key and column that indicates whether the keys are duplicates or not and a group key that tell us if the key belongs to the same group. For example, in Table A ...
0
votes
0answers
19 views

Filtering Spatial Data in Apache Spark

I am currently solving a problem involving GPS data from buses. The issue I am facing is to reduce computation in my process. There are about 2 billion GPS-coordinate points (Lat-Long degrees) in one ...
0
votes
0answers
18 views

Avoid rubbish or unknown data to be classified in scikit-learn

I have this piece of code below that classifies the cities related to phrases using the scikit-learn package. But I got some problems with the classification on some of the phrases. import numpy as ...
-1
votes
0answers
16 views

R algorithm for deleting rows with artefacts

I'm analyzing DEM data of rivers with R and need assistance with the data processing. The DEM data include many artifacts, where the river longitudinal profile goes slightly uphill, which is in fact ...
1
vote
2answers
34 views

Optimal method to select `n` farthest points from a set of 2-D points

I have set of (latitude,longitude) coordinates. (13.0180552378288,77.6811561227539) (12.9905166666667,77.7278116666667) (12.9381400000000,77.7486000000000) and so on..............there can be upto ...
0
votes
0answers
15 views

Phreak algorithm for rules engine

I am writing a custom rules engine and would like to implement phreak algorithm for the same. Can someone provide a link to page that shows its steps ?
0
votes
0answers
29 views

A*(Star) Prolog

I have an A*(Star) Algorithm in prolog, and I need receive a list of destinations instead a single destination, and it should past for every element of the list and then back to the start. NOTE: It ...
0
votes
1answer
13 views

How would I find the top 3 words from a textfile that are next to each other

This will be done in python but I would like to know how to approach it. So say I have a text file with the contents of a book. I don't want to find the top word, I want to find the top 3 words in a ...
-1
votes
1answer
52 views

Is there any good way to draw a lot of projectiles efficiently in a game? [on hold]

I met the problem that I need to draw multiple (maximum 2000 projectiles) projectiles in my game. My solution is using a vector to store my projectiles object. I create new projectiles by simply ...
-3
votes
1answer
31 views

rem=a%b a=a/b Find Last Possible Value Of a>0

Basically, what I want is to find an efficient way to do this: int counter=0; vector<int> myvector; void Computer(int N,int M){ while(N>0){ myvector.push_back(N%M); N=...
0
votes
2answers
51 views

Is There a Standard Algorithm to Copy Until?

I am using an istream_iterator<char> it, so I cannot iterate over the range in reverse (or iterate over it twice, without a great deal of hastle.) I want to copy until a condition is met. Is ...
-2
votes
0answers
6 views

Algorithm for sensor signal order?

A light and two sensors A and B. the light to be on, if sensor A detects signal before sensor B and the light off, when sensor B detects signal before sensor A. i need algorithm for this.
8
votes
1answer
209 views

How to implement a constraint solver for 2-D geometry?

I have a set of metallic sliding pieces which are constrained to the x and y axis in following way: I would need to maximize the horizontal distance among all pieces constrained by the same slider ...
0
votes
0answers
18 views

Optimizing Best Search algorithm in CLISP - Graph Search

I'm implementing a best search algorithm in cLISP for the game Vector Race. So far I have an A* algorithm with a simple diagonal distance heuristic function. I'm trying to optimize it as much as ...
0
votes
0answers
12 views

Confusion related to the time complexity of an algorithm

I was going through this algorithm http://codereview.stackexchange.com/questions/63921/print-all-nodes-from-root-to-leaves In one of the comments it is mentioned that printing the paths from the root ...
0
votes
0answers
11 views

function objects and algorithm to to find numbers within a range in a vector in C++

I am trying to write a function in C++ that will receive a vector and will print all numbers between 10 and 30 (both inclusive) from that vector, also will print number of numbers found in the range, ...
54
votes
26answers
23k views

Algorithm to calculate number of intersecting discs

Given an array A of N integers we draw N discs in a 2D plane, such that i-th disc has center in (0,i) and a radius A[i]. We say that k-th disc and j-th disc intersect, if k-th and j-th discs have at ...
3
votes
4answers
134 views
+50

Find free port not in use for apps - find some algorithm

I use the following API in my program to detrmine free port and provide it to application to run portscanner.findAPortNotInUse(3000, 65000, '127.0.0.1', function(error, port) { console.log('...
-8
votes
0answers
37 views

How to find area covered by car, which travels in straight lines(Left, right is included) [on hold]

Details: A car is at start point, say START. Assume: 1. It travels 1km straight, 1km right, 1km right, 1km right. So it will reach its START point finally. Here the area covered by the car will be ...
0
votes
6answers
63 views

How to get a sorted list from a list which contains many list that have already been sorted? [on hold]

For example, I have a list with many many elements x = [[1, 2, 3], [3, 4, 5],[2, 3, 4], [4, 7, 8], ...] each element has already sorted. How can I get a list named y that is from x's elements and ...
0
votes
1answer
96 views

Implementing a for loop from an algorithm in c

I am only learning c and I am trying to implement a for loop from an algorithm. I am so so confused in how to implement it, please see my attempt below. Any help or thoughts would be greatly ...
0
votes
1answer
57 views

why does the Integer.paseInt() algorithm calculate negative result finally in sun jdk

In jdk source,I have some questions about the Integer's parseInt(String str,int radix) algorithm.let's see the code source below. multmin = limit / radix; while (i < len) { ...
1
vote
2answers
668 views

Anyone having any leads on a 'reading time algorithm'?

Just curious how to calculate the length of time it would take someone to read a paragraph with x characters and/or y words. Any thoughts on this?
5
votes
1answer
2k views

Yen's improvement to Bellman-Ford

I stumbled with famous Yen's optimization of Bellman-Ford algorithm that I got initially from Wikipedia, then I found the same improvement in several textbooks in Exercise section (for example, this ...