public DynProg(List<Product> products, int sum) {
	
		int n = products.size();
		
		/* allocate nodes */
		nodes = new Node[n+1][sum+1];
		for (int i = 0; i <= n; i++)
			for (int j = 0; j <= sum; j++)
				nodes[i][j] = new Node();
		
		/* fill the 2D array */
	    for (int i = 1; i <= n; i++) {
    		Product p = products.get(i-1);
	    	for (int j = 1; j <= sum; j++) {
	    		/* if the element i is equal to sum (j), then
	    		 * there is a subset:
	    		 */
	    		if (((int) p.getPrice()) == j)
	    			nodes[i][j].addSubset(new Subset(p));
	    		
	    		/* add all subsets of nodes[i-1][j] here in [i][j] */
	    		for (Subset s : nodes[i-1][j].getAllSubsets()) 
	    			nodes[i][j].addSubset(s);
	    	
	    		/* get all subsets of nodes[i-1][sum-p] and add p */
	    		if (j > ((int)p.getPrice()))
	    			for (Subset s : nodes[i-1][j-((int)p.getPrice())].getAllSubsets())
	    				nodes[i][j].addSubset(s.addElement(p));
	    	}
	    }
		
	}