{VERSION 5 0 "IBM INTEL NT" "5.0" } {USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 0 1 255 0 0 1 0 1 0 2 1 2 0 0 0 1 }{CSTYLE "_cstyle2" -1 203 "Times" 0 1 0 0 0 0 0 0 0 2 2 2 0 0 0 1 }{CSTYLE "_cstyle1" -1 204 "Times" 0 1 0 0 0 0 0 0 0 2 2 2 0 0 0 1 }{CSTYLE "_cstyle3" -1 206 "Times" 0 1 0 0 0 0 0 0 0 2 2 2 0 0 0 1 }{PSTYLE "_pstyle4" -1 203 1 {CSTYLE "" -1 -1 "Times" 0 1 0 0 0 0 0 0 0 2 2 2 0 0 0 1 }0 0 0 -1 -1 -1 2 0 2 0 2 2 -1 1 }{PSTYLE "_psty le5" -1 204 1 {CSTYLE "" -1 -1 "Courier" 0 1 255 0 0 1 0 1 0 2 1 2 0 0 0 1 }0 0 0 -1 -1 -1 2 0 2 0 2 2 -1 1 }{PSTYLE "_pstyle6" -1 205 1 {CSTYLE "" -1 -1 "Times" 0 1 0 0 0 0 0 0 0 2 2 2 0 0 0 1 }0 0 0 -1 -1 -1 2 0 2 0 2 2 -1 1 }{PSTYLE "_pstyle7" -1 206 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 2 2 2 0 0 0 1 }0 0 0 -1 -1 -1 2 0 2 0 2 2 -1 1 } {PSTYLE "_pstyle8" -1 207 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 2 2 2 0 0 0 1 }0 0 0 -1 -1 -1 1 0 1 0 2 2 -1 1 }} {SECT 0 {EXCHG {PARA 203 "" 0 "" {TEXT 204 3 "01." }{TEXT 204 0 "" }}} {EXCHG {PARA 204 "> " 0 "" {MPLTEXT 1 0 23 "Huffman:=proc(Alphabet)" } {MPLTEXT 1 0 0 "" }{MPLTEXT 1 0 11 "\nlocal res;" }{MPLTEXT 1 0 0 "" } {MPLTEXT 1 0 28 "\nres:=HuffmanList(Alphabet);" }{MPLTEXT 1 0 0 "" } {MPLTEXT 1 0 18 "\nif type(res,list)" }{MPLTEXT 1 0 0 "" }{MPLTEXT 1 0 21 "\n then return res[2]" }{MPLTEXT 1 0 0 "" }{MPLTEXT 1 0 19 "\n \+ else return res " }{MPLTEXT 1 0 0 "" }{MPLTEXT 1 0 7 "\nend if" } {MPLTEXT 1 0 0 "" }{MPLTEXT 1 0 10 "\nend proc:" }{MPLTEXT 1 0 0 "" }} }{EXCHG {PARA 203 "" 0 "" {TEXT 204 3 "02." }{TEXT 204 0 "" }}}{EXCHG {PARA 204 "> " 0 "" {MPLTEXT 1 0 27 "HuffmanList:=proc(Alphabet)" } {MPLTEXT 1 0 0 "" }{MPLTEXT 1 0 42 "\nlocal j,k,alphabet,createcode,er st,zweit;" }{MPLTEXT 1 0 0 "" }{MPLTEXT 1 0 60 "\nif not(abs(sum(Alpha bet[k][2],k=1..nops(Alphabet))-1)<0.01)" }{MPLTEXT 1 0 0 "" }{MPLTEXT 1 0 32 "\n then return \"falsche Eingabe\"" }{MPLTEXT 1 0 0 "" } {MPLTEXT 1 0 8 "\nend if;" }{MPLTEXT 1 0 0 "" }{MPLTEXT 1 0 20 "\nalph abet:=Alphabet;" }{MPLTEXT 1 0 0 "" }{MPLTEXT 1 0 60 "\ncreatecode:=[s eq([alphabet[k][1],[]],k=1..nops(alphabet))];" }{MPLTEXT 1 0 0 "" } {MPLTEXT 1 0 36 "\nfor j from 1 to nops(alphabet)-1 do" }{MPLTEXT 1 0 0 "" }{MPLTEXT 1 0 98 "\n alphabet:=sort(alphabet,(x,y)->if op(2,x)<= op(2,y) then return true else return false end if );" }{MPLTEXT 1 0 0 "" }{MPLTEXT 1 0 21 "\n erst:=alphabet[1];" }{MPLTEXT 1 0 0 "" } {MPLTEXT 1 0 41 "\n alphabet:=alphabet[2..nops(alphabet)];" } {MPLTEXT 1 0 0 "" }{MPLTEXT 1 0 22 "\n zweit:=alphabet[1];" } {MPLTEXT 1 0 0 "" }{MPLTEXT 1 0 41 "\n alphabet:=alphabet[2..nops(alp habet)];" }{MPLTEXT 1 0 0 "" }{MPLTEXT 1 0 38 "\n for k from 1 to nop s(createcode) do" }{MPLTEXT 1 0 0 "" }{MPLTEXT 1 0 54 "\n if member (createcode[k][1],convert(erst[1],list))" }{MPLTEXT 1 0 0 "" } {MPLTEXT 1 0 54 "\n then createcode[k][2]:=[0,op(createcode[k][2] )]" }{MPLTEXT 1 0 0 "" }{MPLTEXT 1 0 12 "\n end if;" }{MPLTEXT 1 0 0 "" }{MPLTEXT 1 0 10 "\n end do;" }{MPLTEXT 1 0 0 "" }{MPLTEXT 1 0 39 "\n for k from 1 to nops(createcode) do " }{MPLTEXT 1 0 0 "" } {MPLTEXT 1 0 55 "\n if member(createcode[k][1],convert(zweit[1],lis t))" }{MPLTEXT 1 0 0 "" }{MPLTEXT 1 0 54 "\n then createcode[k][2 ]:=[1,op(createcode[k][2])]" }{MPLTEXT 1 0 0 "" }{MPLTEXT 1 0 12 "\n \+ end if;" }{MPLTEXT 1 0 0 "" }{MPLTEXT 1 0 10 "\n end do;" } {MPLTEXT 1 0 0 "" }{MPLTEXT 1 0 69 "\n alphabet:=[[cat(erst[1],zweit[ 1]),erst[2]+zweit[2]],op(alphabet)];" }{MPLTEXT 1 0 0 "" }{MPLTEXT 1 0 8 "\nend do;" }{MPLTEXT 1 0 0 "" }{MPLTEXT 1 0 30 "\nreturn [alphabe t,createcode];" }{MPLTEXT 1 0 0 "" }{MPLTEXT 1 0 10 "\nend proc:" } {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 203 "" 0 "" {TEXT 204 3 "03." } {TEXT 204 0 "" }}}{EXCHG {PARA 204 "> " 0 "" {MPLTEXT 1 0 64 "Alphabet :=[[\"A\",0.1],[\"B\",0.12],[\"C\",0.18],[\"D\",0.2],[\"E\",0.4]];" } {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 203 "" 0 "" {TEXT 204 3 "04." } {TEXT 204 0 "" }}}{EXCHG {PARA 204 "> " 0 "" {MPLTEXT 1 -1 18 "Huffman (Alphabet);" }{MPLTEXT 1 0 0 "" }}}{PARA 205 "" 0 "" {TEXT 203 0 "" }} {PARA 206 "" 0 "" {TEXT 206 0 "" }}{PARA 207 "" 0 "" {TEXT -1 0 "" }}} {MARK "1 0 0" 0 }{VIEWOPTS 1 1 0 1 1 1803 1 1 1 1 }{PAGENUMBERS 0 1 2 33 1 1 }