An algorithm is a sequence of well-defined steps that defines in abstract the solution to a problem.
0
votes
0answers
23 views
moving average accuracy?
I have some data where people vote on things, and it would be nice to have an average for each item of how everyone who has voted on it has voted. You can think of the votes as a stream of constantly ...
1
vote
2answers
50 views
Find the longest prefix of bit arrays
I'm trying to find a fast algorithm that search the longest prefix of multiple bit arrays. In my application, those bit arrays can be infinitely long and of variable length. For example, if I have ...
1
vote
3answers
30 views
check if two segments on the same circle overlap / intersect
Given two circle segments of the same circle: A=[a1, a2] and B=[b1, b2], with:
a1, a2, b1, b2 values in degree between -inf and +inf
a1 <= a2 ; b1 <= b2
a2-a1<=360; b2-b1<=360
How can ...
1
vote
2answers
91 views
Generate subsequences
I have a string like "0189", for which I need to generate all subsequences, but the ordering of the individual characters must be kept, i.e, here 9 should not come before 0, 1 or 8. Ex: 0, 018, 01, ...
1
vote
1answer
39 views
How to improve Dijkstra algorithm when querying n times?
I'm currently working on a problem at Codechef. You can find the problem statement here:
Delivery Boy
In short, the problem is asking to query n times the shortest path from a start to an end. My ...
0
votes
3answers
62 views
number of subarrays where sum of numbers is divisible by K
Given an array, find how many such subsequences (does not require to be contiguous) exist where sum of elements in that subarray is divisible by K.
I know an approach with complexity 2^n as given ...
0
votes
3answers
41 views
Math/Algorithm for Simple Game Programming (Newbie)? [closed]
I am a newbie on game programming, i usually programmed enterprise software.
my questions is which math do i need to learn in order for me to create these games
Snake game
Tetris
Card Games like ...
1
vote
1answer
34 views
Random in first out storage structure
I am looking for a suitably efficient storage structure for processing data that arrives in random order, but must be processed and/or removed from the stack in a specified order.
To make this ...
0
votes
1answer
26 views
php mysql query finding closest results
How would the best way to approach this problem be?
Search for user by first name, where the parameter is a string. The result should display a list
of the 10 users whose first name is closest to ...
1
vote
2answers
36 views
Traverse an n-dimensional array when dimensions are variable
I need to traverse an n-dimensional array. The array is build and passed from another function and number of dimensions is not known in advance. This needs to be done in a primitive language similar ...
2
votes
1answer
41 views
Finding nCk that can have huge values of n and k
Firstly this is not my homework ..I am stuck on a question during my practice.
I want to compute the value of this expression:
ans=(2^huge)%p..
where:
huge=n1Ck1+ n2Ck2 +n3Ck3 ..... [n1,n2.. can be ...
5
votes
1answer
115 views
What would be a good implementation of iota_n (missing algorithm from the STL)
With C++11, the STL has now a std::iota function (see a reference). In contrast to std::fill_n, std::generate_n, there is no std::iota_n, however. What would be a good implementation for that? A ...
-1
votes
2answers
78 views
An algorithm find the previous number?
I have an algorithm in which I add a number and the last digit of that number, for example:
mynumber = abc;
result = abc + c;
Is it possible to determine the previous number given the current ...
1
vote
0answers
47 views
How to implement segment trees with lazy propagation?
I have searched on internet about implementation of Segment trees but found nothing when it came to lazy propagation.There were some previous questions on stack overflow but they were focused on ...
1
vote
4answers
63 views
Algorithm to parse irregular comma-separated values
Say we have a list with several descriptions of things. A description consists of comma-separated words. Lets take the following list as an example (each line is a separate description):
white, ...