Data-structure to “map” collections to states in a dynamic-programming algorithm?

It's impossible to answer without knowing the structure of your solutions But, if the solution for k is obtainable from the solution of (k-1) by inserting a building be into position j, then you can have simply an hashmap mapping integer I to the "delta" between the solution for I and the solution for i-1, expressed by a couple But having to deal explicitly with deltas can be hideous, because you need to do traversing to get a solution. You can solve this by let the delta know the referenced deltas (i.e. , passing the delta for (k-1) in the constructor of the delta for k), and then exposing a method getSolution() which performs the actual traversing You can extend this idea to similar solution structures.

It's impossible to answer without knowing the structure of your solutions. But, if the solution for k is obtainable from the solution of (k-1) by inserting a building be into position j, then you can have simply an hashmap mapping integer I to the "delta" between the solution for I and the solution for i-1, expressed by a couple. But having to deal explicitly with deltas can be hideous, because you need to do traversing to get a solution.

You can solve this by let the delta know the referenced deltas (i.e. , passing the delta for (k-1) in the constructor of the delta for k), and then exposing a method getSolution() which performs the actual traversing. You can extend this idea to similar solution structures.

You can use a LinkedHashSet for the key and the value is the cost of building the Buildings contained in the set in its iteration order. It's a bit of a hack but according hashCode and equals it should work. It you prefer to be more explicit go with the hashmap of set to pair of cost and build order.

If your solutions look like ABC,cost1, ABCD,cost2, create a linked list d-> c-> b-> a. Store solutions as tuples of cost and a reference to the last element contained in your Solution (the earliest in the list).

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions