rkalyankumar
BAN USERUse a ConcurrentLinkedQueue or even a ConcurrentLinkedDeque (from java.util.concurrent package or another equivalent one if you prefer to write or from a different library/language) data structure as the Message container in the server side. You can then vary pub-sub implementations around this be it one-way publisher, one pub many consumer etc. Notice that you may actually want to augment the Queue data structure a bit to provide a queue name and have publishers/subscribers to communicate using that named queue.
- rkalyankumar April 06, 2015median of medians algorithm is the way to go. As dhruba.work rightly pointed CLRS book has a chapter on this.
- rkalyankumar March 27, 2014@ravisingh:
This is a knapsack problem with repititions allowed. The solution would look something like below (simple and stupid pseduo-code):
knapsack(w)
knapack(0) = 0
for each wi = 1 to W:
knapsack(wi) = max{K(w - wi) + vi : wi <= w}
return knapsack(W)
where W = 500
wi is the individual prices of the books per bundle
w is the current quantity (multiples of quantities per bundle).
I am not sure if I have made any honest attempt to think about the right solution to the problem, but the problem looks like knapsack problem with repititions as described in algorithms book by Vazirani, Papadimitrou & Dasgupta.
Please validate my assumptions and answer if anything is misleading or wrong.
Well it could be a knapsack problem as well solvable using DP technique. Trying to come up with a code!
- rkalyankumar February 22, 2013Needs more clarity (see below points):
1) How much memory is available to hold the numbers (since sizeof(int) = 4 & that 1M numbers would occupy atleast 1M * 4 memory size which is pretty huge)?
2) How are the numbers provided as input? for e.g. are they read from any file(s) on disk?
cslibrary.stanford.edu/109/TreeListRecursion.html
- rkalyankumar July 16, 2012
Can we use longest path algorithm on a graph to determine the longest length ladder needed for the player? Possible approach would be (Comment if I am not right in the approach):
- rkalyankumar April 11, 20151. DFS in 4 directions (North, South, West & East)
2. Construct path decomposition from start to finish while traversing from start to finish in all four directions as in step 1.
3. Apply DP to find the path decomposition to find the longest path.
Look up wikipedia on longest path traversal