Clear[Huffman]
\(Huffman[Alphabet_] := 
      Module[{k, alphabet, createcode, erst, zweit}, 
        If[\(! Abs[Sum[Alphabet[\([k, 2]\)], {k, Length[Alphabet]}] - 1. ] < 
              0.01\), Return["falsche Eingabe"]]; \ 
        alphabet = Alphabet; 
createcode = 
          Table[{alphabet[\([k, 1]\)], {}}, {k, 
              Length[alphabet]}]; 
Do[
          alphabet = 
            Sort[alphabet, #1[\([2]\)] ≤ #2[\([2]\)] &]; 
erst = First[alphabet]; \ 
          alphabet = Rest[alphabet]; 
zweit = 
            First[alphabet]; \ 
          alphabet = Rest[alphabet]; 
Do[
            If[\(! FreeQ[erst[\([1]\)], createcode[\([k, 1]\)]]\), 
              PrependTo[createcode[\([k, 2]\)], 0]], {k, 
              Length[createcode]}]; 
Do[
            If[\(! FreeQ[zweit[\([1]\)], 
                  createcode[\([k, 1]\)]]\), 
PrependTo[
                createcode[\([k, 2]\)], 1]], {k, 
              Length[createcode]}]; 
PrependTo[
            alphabet, {{erst[\([1]\)], zweit[\([1]\)]}, 
              erst[\([2]\)] + zweit[\([2]\)]}], {j, 
            Length[alphabet] - 1}]; \ 
{alphabet, 
          createcode}]\)

Clear[Huffman, HuffmanList]
Huffman[
          Alphabet_] := HuffmanList[Alphabet][[2]];

\(HuffmanList[Alphabet_] := 
      Module[{k, alphabet, createcode, erst, zweit}, 
        If[\(! Abs[Sum[Alphabet[\([k, 2]\)], {k, Length[Alphabet]}] - 1. ] < 
              0.01\), Return[{\(,\)\("falsche Eingabe"\)}]]; \ 
        alphabet = Alphabet; 
createcode = 
          Table[{alphabet[\([k, 1]\)], {}}, {k, 
              Length[alphabet]}]; 
Do[
          alphabet = 
            Sort[alphabet, #1[\([2]\)] ≤ #2[\([2]\)] &]; 
erst = First[alphabet]; \ 
alphabet = 
            Rest[alphabet]; 
zweit = 
            First[alphabet]; \ 
alphabet = 
            Rest[alphabet]; 
Do[
            If[\(! FreeQ[erst[\([1]\)], createcode[\([k, 1]\)]]\), 
              PrependTo[createcode[\([k, 2]\)], 0]], {k, 
              Length[createcode]}]; 
Do[
            If[\(! FreeQ[zweit[\([1]\)], 
                  createcode[\([k, 1]\)]]\), 
PrependTo[
                createcode[\([k, 2]\)], 1]], {k, 
              Length[createcode]}]; 
PrependTo[
            alphabet, {{erst[\([1]\)], zweit[\([1]\)]}, 
              erst[\([2]\)] + zweit[\([2]\)]}], {j, 
            Length[alphabet] - 1}]; \ 
{alphabet, 
          createcode}]\)

Alphabet = {{"A", 0.1}, {"B", 0.12}, {"C", 0.18}, {"D", 
          0.2}, {"E", 0.4}}

Huffman[Alphabet]