實現背包問題
package problem
1. 問題描述
假設有一個能裝入總體積為T的背包和n件體積分別為w1 , w2 , … , wn 的物品,能否從n件物品中挑選若干件恰好裝滿背包,即使w1 +w2 + … + wn=T,要求找出所有滿足上述條件的解。例如:當T=10,各件物品的體積{1,8,4,3,5,2}時,可找到下列4組解: (1,4,3,2)、(1,4,5)、(8,2)、(3,5,2)。
2. 基本要求
讀入T、n、w1 , w2 , … , wn
3.提示:
可利用遞歸方法:若選中w1 則問題變成在w2 , … , wn 中挑選若干件使得其重量之和為T- w1 ,若不選中w1,則問題變成在w2 , … , wn 中挑選若干件使得其重量之和為T 。依次類推。
也可利用回溯法的設計思想來解決背包問題。首先將物品排成一列,然后順序選取物品裝入背包,假設已選取了前i 件物品之后背包還沒有裝滿,則繼續選取第i+1件物品,若該件物品“太大”不能裝入,則棄之而繼續選取下一件,直至背包裝滿為止。但如果在剩余的物品中找不到合適的物品以填滿背包,則說明“剛剛”裝入背包的那件物品“不合適”,應將它取出“棄之一邊”,繼續再從“它之后”的物品中選取,如此重復,,直至求得滿足條件的解,或者無解。
注:沒壓縮密碼
標簽:
package
problem
體積
w2
上傳時間:
2014-01-18
上傳用戶:yxgi5
Hard-decision decoding scheme
Codeword length (n) : 31 symbols.
Message length (k) : 19 symbols.
Error correction capability (t) : 6 symbols
One symbol represents 5 bit.
Uses GF(2^5) with primitive polynomial p(x) = X^5 X^2 + 1
Generator polynomial, g(x) = a^15 a^21*X + a^6*X^2 + a^15*X^3 + a^25*X^4 + a^17*X^5 + a^18*X^6 + a^30*X^7 + a^20*X^8 + a^23*X^9 + a^27*X^10 + a^24*X^11 + X^12. Note: a = alpha, primitive element in GF(2^5) and a^i is root of g(x) for i = 19, 20, ..., 30.
Uses Verilog description with synthesizable RTL modelling.
Consists of 5 main blocks: SC (Syndrome Computation), KES (Key Equation Solver), CSEE (Chien Search and Error Evaluator), Controller and FIFO Register.
標簽:
symbols
length
Hard-decision
Codeword
上傳時間:
2014-07-08
上傳用戶:曹云鵬