문제

In 1/0 Knapsack Problem, one can implement it dynamically with two for loops, like on this site: http://www.bogotobogo.com/Algorithms/knapsack.php

How can i implement it with a priority queue and optimize it with multithreading?

도움이 되었습니까?

해결책

In the algorithm in the section "0-1 Knapsack - Dynamic Programming", the inner loop can be parallelized. The execution of the loop's body for different values of jw can be executed in parallel as the calculation of the value for m[i][jw] does not require values m[i][jw'] where jw'!=jw, i.e. any iteration does not depend on previous iterations.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top