Problema da mochila: diferenças entre revisões

Conteúdo apagado Conteúdo adicionado
Etiqueta: gettingstarted edit
Linha 117:
'''Uso da matriz KEEP'''
 
Inicializar <math>KEEP(0,j) = 0
</math> para todo j pertencente a
{1,...,n}  e <math>KEEP(w,0) = 0
</math> para todo w
pertencente a {1,...,n}
 
Linha 126 ⟶ 128:
 
se
wj <= w:
 
se
se K(w,j-1)<K(w – wj, j – 1) + vj
<nowiki>:</nowiki>
 
KEEP(w,j) = 1
Linha 136:
 
Inicializar int
<math>Remaining weigth = null
remaning_weight = W
</math><math>
</math>
 
Inicializar lista solução<math>Solucao = vazionull
</math>
 
para item maior
Linha 145 ⟶ 148:
se keep(remaning_weight,item) = 1:
 
remaning_weight = remaning_weight – w(item)
remaning_weight – w(item)
 
adicione item a lista solucao
solução
 
item = item – 1
 
Retorne Solução<math>Solucao
</math>
 
'''Código em java para o problema limitado'''