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.
0
votes
0answers
9 views
generating combinations in java for a list of list
I have list of list ( list< list < string > >) the lists can be of any size.
Example:
My outer list size is: 4
contents of the list
list1 a,b,c
list2 d,b,f,m
list3 x,a
list4 b,e,d,m,a
...
0
votes
0answers
6 views
How to optimize the scheduling algorithm to minimize the total travel time?
I am stuck with a problem where i have to schedule the movement of trains. The problem can be(shall be) realized like the scheduling of IP packets over a network. Each node shall have the routing ...
0
votes
1answer
11 views
how to reduce truth table with large number of input variables
Algos to reduce the expression generated by truth table having number of input variable greater then 6.
More generic question would be::
Algos to reduce the expression generated by truth table ...
2
votes
2answers
40 views
In a snake game, how can a move a snake that has distinct pieces?
I've looked at some examples that build a snake game in javascript and they seem to move the snake with this algorithm:
place a piece where you're going to be next tick
remove the last piece from ...
0
votes
1answer
14 views
Lucene 4.1.0 Porter Stemmer not work properly
I work with my App in Java and i use Lucene 4.1.0 to use Porter Stemmer method.
I have read and implementing this
this is my code
import org.apache.lucene.analysis.snowball.*;
import ...
3
votes
3answers
83 views
Cannot understand this prime generator algorithm in my textbook
I am studying Elements of Programming Interviews, and I am stuck on a problem.
It is about writing a c++ function for finding all prime numbers from 1 to n, for a given n.
vector<int> ...
0
votes
0answers
24 views
LRU simulation logical isusses in python
I was trying to make LRU paging algorithm usage simulation in python. As argument from bash we take 2 parameters , number of frames and pages. I believe that implementation is ok and program is ...
-3
votes
0answers
35 views
algorithm for counting number of objects ( object: connected black pixels) in the binary image [closed]
i have no experience writing algorithms but i tried to write an algorithm for the particular problem counting object on binary image. I created some objects on binary image by connected black pixels ...
0
votes
0answers
25 views
Pouring water algorithm gets WA on SPOJ
I'm doing an algorith POUR1 on SPOJ:
Given two vessels, one of which can accommodate a litres of water and the other - b litres of water, determine the number of steps required to obtain exactly c ...
1
vote
2answers
44 views
generate all combinations of 0's and 1's for a given length with min and max 1's given
I would like to know if there is an efficient algorithm to generate all the combinations of 0's and 1's with length n given the minimum and maximum amount of 1's.
Example:
n=4 min=2 max=3
0011 ...
1
vote
4answers
67 views
Any algorithm that mangles/hashes a string but can be matched against?
Usage case: client needs to send a huge string over HTTP. The server replies whether the string contains some substring. However, huge string is huge. This system is as a result really inefficient. ...
0
votes
1answer
60 views
Divide and conquer algorithm applied in finding a peak in an array.
For an array a: a1, a2, … ak, … an, ak is a peak if and only if ak-1 ≤ ak ≥ ak+1 when 1 < k and k < n. a1 is a peak if a1 ≥ a2, and an is a peak if an-1 ≤ an. The goal ...
1
vote
1answer
53 views
Maximizing profit for given stock quotes, my solution in java
You are given the stock prices for a set of days . Each day, you can either buy one unit of stock, sell any number of stock units you have already bought, or do nothing. What is the maximum profit you ...
0
votes
1answer
13 views
grid point algorithm (finding the point in grid)
I am searching for an algorithm such as the closest pair of points algorithm
Instead of an arbitrary distance between all of the points, I have a grid system set up with the 4 points being the ...
0
votes
3answers
79 views
What's wrong with my Extended Euclidean Algorithm (python)?
My algorithm to find the HCF of two numbers, with displayed justification in the form r = a*aqr + b*bqr, is only partially working, even though I'm pretty sure that I have entered all the correct ...