PROPOSAL TUGAS AKHIR II - USU Institutional Repository

7 downloads 127 Views 118KB Size Report
LAMPIRAN. 1. Proses pembentukan pohon biner. Algoritma Huffman y:8 b:7 s:8 f: 4 h:4 o :3 c:1 . :3 j:1. , :2. P:1. D:1. A:1 r:11 d:17 u:15 m:13 t:13 l:9 k:19 n:36 e:29.
LAMPIRAN 1. Proses pembentukan pohon biner Algoritma Huffman A:1

D:1

m:13

t:13

1.

P:1

c:1

P:1

u:15

j:1

c:1

j:1

g:16

d:17

, :2

2

2.

j:1

t:13

u:15

, :2

2

3.

m:13

. :3

c:1

j:1

m:13

t:13

i:23

e:29

n:36

o :3

f:4

h:4

k:19

i:23

e:29

d:17

. :3

o :3

g:16

d:17

k:19

i:23

e:29

2

. :3

o :3

3

f:4

h:4

D:1

j:1 d:17

g:16

f:4

l:9

y:8

r:11

p:12

p:12

a:52

spasi:47

s:8

b:7

y:8

spasi:47

n:36

b:7

s:8

y:8

l:9

k:19

i:23

b:7

2

e:29

s:8

n:36

y:8

l:9

spasi:47

r:11

l:9

a:52

p:12

2

P:1

c:1

g:16

d:17

A:1

k:19

D:1

i:23

e:29

n:36

spasi:47

r:11

p:12

r:11

p:12

a:52

, :2

4

h:4

, :2

u:15

r:11

l:9

a:52

s:8

n:36

h:4

f:4

u:15

u:15

y:8

s:8

spasi:47

b:7

D:1

3

o :3

g:16

2

A:1

t:13

h:4

A:1

2

P:1

4.

t:13

. :3

f:4

c:1

P:1

m:13

k:19

b:7

o :3

D:1

A:1 m:13

. :3

, :2

a:52

5.

3

j:1

f:4

2

c:1

P:1

6.

u:15

t:13

2

c:1

m:13

7.

t:13

6

. :3

u:15

3

o :3

j:1

d:17

g:16

s:8

8.

k:19

7

3

j:1

s:8

n:36

8

k:19

i:23

e:29

r:11

l:9

n:36 r:11

spasi:47

p:12

n:36

p:12

spasi:47

a:52

m:13

t:13

t:13

13

A:1

u:15

g:16

D:1

A:1

c:1 spasi:47

r:11

a:52

p:12

m:13

6

n:36

a:52

2

2

c:1

p:12

4

l:9

2

, :2

e:29

4

h:4

f:4

P:1

d:17

l:9

2

y:8

y:8

e:29

i:23

8

h:4

e:29

r:11

, :2

y:8

, :2

i:23

l:9

f:4

k:19

f:4

i:23 s:8

3

o :3

P:1 d:17

7

j:1

7

b:7

k:19

b:7

D:1

A:1

y:8

s:8

o :3

. :3

d:17

g:16

. :3

b:7

D:1

6

2

P:1

A:1

4

h:4

6

2

, :2

m:13

4

h:4

. :3

D:1

spasi:47

a:52

u:15 b:7

o :3

g:16

9.

8

y:8

10.

l:9

m:13

2

c:1

. :3

A:1

k:19

r:11

13

t:13 6

2

d:17

p:12

4

h:4

P:1

r:11

l:9

7

o :3

3

j:1

n:36

e:29

m:13

p:12

b:7

D:1

i:23

spasi:47

13

t:13 6

. :3

15

7

o :3

3

j:1

11. p:12

k:19

m:13

i:23

e:29

13

t:13 6

. :3

n:36

, :2

16

g:16

8

y:8

s:8

2

b:7

o :3

7

3

j:1

16

g:16

s:8

e:29

n:36

spasi:47

d:17

A:1

D:1

4

2

, :2

20

k:19

l:9 h:4

f:4

a:52

c:1

8

y:8

P:1 i:23

2

a:52

15

u:15

4

h:4

f:4

, :2

spasi:47

s:8

f:4

P:1 d:17

g:16

a:52

u:15 b:7

15

u:15

2

c:1

A:1

D:1

r:11

12

13

t:13 6

. :3

15

u:15 b:7

o :3

7

3

j:1

16

g:16

l:9

2

, :2

13

spasi:47

n:36 15

u:15

7

3

j:1

16

16

spasi:47

d:17

D:1

20

i:23

25

r:11

p:12

6

A:1

. :3

20

k:19

25

i:23

26

r:11

p:12

m:13

spasi:47

13

t:13

a:52

. :3 D:1

30

e:29

6

A:1

o :3

a:52

2

c:1

b:7

D:1

4

2

13

t:13

m:13

2

c:1

l:9 h:4

26

4

8

y:8

n:36

k:19

2

g:16

P:1

d:17

h:4

, :2

n:36

A:1

l:9

P:1

14

c:1

8

y:8

f:4

e:29

m:13

p:12

a:52

g:16

s:8

r:11

2

P:1 e:29

25

i:23

4

h:4

f:4

20

k:19

8

y:8

s:8

d:17

15

u:15

b:7

7

o :3

3

j:1

s:8

f:4

, :2

15

d:17

k:19

i:23

20

l:9

r:11

25

26

p:12

m:13

13

t:13 6

b:7

7

8

y:8

s:8

3

j:1

16

g:16

15

u:15

o :3

. :3

32

30

e:29

2

, :2 P:1

n:36

spasi:47

4

h:4

f:4

2

c:1

A:1

D:1

spasi:47

a:52

a:52

16 i:23

20

l:9

r:11

25

p:12

26

m:13

13

t:13 6

. :3

32

30

e:29

b:7

o :3

7

3

16

g:16

15

u:15

2

P:1

17

p:12

25

26

m:13

13

t:13 6

. :3

b:7

7

3

j:1

s:8

d:17

4

2

P:1

k:19

2

c:1

A:1

D:1

D:1

A:1

43

l:9 h:4

, :2

c:1

20

8

y:8

f:4

2

36

n:36

16

g:16

15

u:15

o :3

32

30

e:29

k:19

4

h:4

f:4

, :2

j:1

d:17 8

y:8

s:8

36

n:36

r:11

spasi:47

i:23

a:52

18

32

30

e:29

7

16

g:16

15

u:15

3

l:9

19

32

16

g:16

d:17

d:17

2

c:1

36

43

k:19

20

l:9

m:13

r:11

A:1

u:15

13

t:13 6

2

P:1

p:12

30

e:29

26

4

h:4

7

3

D:1

j:1

25

i:23

p:12

59

a:52

51

m:13

6

. :3

30

u:15

13

t:13

32

15

7

b:7 3

o :3 j:1

s:8

f:4

, :2

68

e:29

26

15

b:7

o :3

. :3

spasi:47

o :3

59

a:52

51

25

i:23

r:11

l:9

b:7

D:1

A:1

8

y:8

20

20

. :3

spasi:47

43

k:19

13

t:13

m:13

p:12

r:11

26

6

c:1

36

n:36

25

i:23

2

P:1

a:52

51

4

2

, :2

j:1

20

8

h:4

f:4

spasi:47

43

k:19

d:17

y:8

s:8

36

n:36

16

g:16

s:8

n:36

8

y:8

4

h:4

f:4

2

2

, :2

P:1

c:1

A:1

D:1

21

spasi:47

25

p:12

59

a:52

51

30

e:29

26

m:13

6

15

7

b:7 3

o :3

. :3

32

u:15

13

t:13

68

j:1

79

16

g:16

59

a:52

68

e:29

30

32

u:15

15

2

c:1

7

3

j:1

68

32

16

g:16

8

y:8

A:1

l:9

r:11

spasi:47

i:23

p:12

51

a:52

25

26

m:13

c:1

A:1

D:1

59

e:29

30

13

t:13

. :3

2

o :3

111

6

2

b:7

D:1

4

h:4

P:1

20

k:19

13

t:13

. :3

2

c:1

43

26

m:13

p:12

r:11

98

36

d:17

25

i:23

6

79

n:36

51

spasi:47

4

2

, :2

20

k:19

l:9

h:4

f:4

43

8

P:1

23

d:17

D:1

98

36

16

y:8

s:8

A:1

79

n:36

g:16

4

2

, :2

i:23

r:11

l:9

h:4

f:4

20

k:19

8

P:1

22

d:17

y:8

s:8

43

36

n:36

u:15

b:7

15

7

o :3

3

j:1

s:8

f:4

, :2

24

51

spasi:47

26

m:13

e:29

6

. :3

32

30

13

t:13

68

59

a:52

25

p:12

147

111

98

u:15

b:7

15

7

o :3

3

j:1

79

16

g:16

8

P:1

25

68

16

g:16

d:17

20

k:19

l:9

r:11

spasi:47

51

a:52

25

i:23

p:12

26

m:13

A:1

D:1

30

13

t:13

. :3

2

59

e:29

6

2

c:1

D:1

111

4

h:4

P:1

43

36

8

y:8

A:1

c:1

98

79

n:36

2

209

147

32

r:11

l:9

2

, :2

i:23

4

h:4

f:4

20

k:19

d:17

y:8

s:8

43

36

n:36

u:15

b:7

15

7

o :3

3

j:1

s:8

f:4

, :2

356

26

209

147

68

32

16

43

36

n:36

g:16

98

79

d:17 8

y:8

20

k:19

51

spasi:47

26

m:13

p:12

. :3

2

P:1

13

u:15

6

2

c:1

A:1

30

e:29

t:13

4

h:4

59

a:52

25

i:23

r:11

l:9

111

15

b:7

7

o :3

3

D:1

j:1

s:8

f:4

, :2

356 0

1 209

147 0

1

0

1

0

32

n:36

68

0

0

8 0 h:4

l:9

1 r:11

p:12

26 1 m:13

1

A:1

D:1

Algoritma Shannon-Fano

1 30

e:29

1

0

13

t:13

4

0

59

0

1

0

6

2

c:1

a:52 1

0

2

P:1

51 0

1

0 1

0

1

0

25

i:23

1

0

spasi:47 1

20

k:19

1

0 y:8

43 0

1

d:17

111 1

0

1

36

1 16

g:16

98

79

0

1

0

u:15

15 0

1 b:7

0

1

. :3

o :3

1

7

3 0 j:1

s:8 1

0

f:4 1 , :2

a:52

spasi:47

s:8

1.

n:36

e:29

f:4

h :4

b:7

y:8

i:23 . :3

k:19

A:1

,:2

o:3

g:16

d:17

u:15

D:1

m:13

t:13

c:1

j:1

P:1

p:12

r:11

l:9

356 0 356 1

.

0

169

187

69

87 2.

356 0

1

187

169

0

1

99

0

1 89

80

88

3.

356 0

1

187

169

0

1

99

88 1

0 a:52

80

0

spasi:47

1

0

1

n:36

89

0

52

1

36

1

0 45

44

44

356

4.

1

0 187 1

0 99 0 a:52

88 1 spasi:47

0 n:36

89

0

52 0

1

80 1

e:29

169

0

1

36 1

i:23

0 k:19

44 1

d:17

0 g:16

1

0 45 1

0 28

25

44 1 20

0 23

1 21

5.

356 0

1 169

187 0

0

1

99

a:52

80

88 1

0

spasi:47

n:36

0

1

89

52

0

1

0

1 i:23

0

1

0

k:19

d:17

g:16 1

6.

1 28

0

0

m:13

0 t:13

p:12

r:11

21

0

1 l:9

15

s:8

1

0

1

11

10

1 169

187 0

0

1

99

a:52

23

20 0

1

1

0

356 0

0

44 1

25 1

u:15

1

45

44

36

0 e:29

1

80

88 1

spasi:47

0

1

n:36

52

0 e:29

1 89

1

0

i:23

0

1

0

1

k:19

d:17

g:16

28

1

0 u:15

1

45

44

36 1

0

0 25 1

m:13

44 1

23

20

0

1

t:13

p:12

0 r:11

1

0

1 l:9

21

0 s:8

15

0

1

y:8

b:7

1

0

1

11 0 f :4

10 1

1

0 7

5

5

7.

356 0

1 169

187 0

0

1

99

a:52

88

80

1

0

1

spasi:47

n:36

52

0

89 1

0

0 e:29

1

44

36 1

0

1

k:19

d:17

g:16

28

1

0

0

m:13

44 1

0 t:13

p:12

1

r:11

21

23

0

1

1

0

20

25 1

u:15

1

45

0

1 i:23

0

0

l:9

s:8

15

0

1

y:8

b:7

1

0

1

10

11 1

0

7

f :4

h :4

o:3

3

2

, :2

1 169

187 0

0

1

99

a:52

.:3

1

1 0

356 0

0

5

5 1 0

0

8.

1

0

80

88 1

0

1

spasi:47

n:36

52

0 e:29

1 89

1

0

i:23

0

1

k:19

d:17

0

0

1

g:16 1

0 u:15

1

45

44

36 1

0

28

25 1

m:13

44 1

23

20

0

1

t:13

p:12

0 r:11

1

0

1 l:9

21

0 s:8

15

0

1

y:8

b:7

1

0

1

11

10 1

0

1

0

f :4 0 h :4

5

7

.:3

5 1

1 0

1 0 o:3

, :2

3

2

0

1

A:1

D:1

1

0 P:1

2

356 0

1 169

187 0

0

1

a:52

80

88

99 0

1

0

spasi:47

n:36

1

89 1

0

52

0 e:29

1

i:23

0 k:19

1 d:17 1

0

1

0

g:16

28

25 1

0 u:15

1

45

44

36 1

0

m:13

44 1

23

20

0

1

t:13

p:12

0 r:11

1

0

1 l:9

21

0 s:8

15

0

1

y:8

b:7

1

0

1

11

10 1

0

1

0

f :4 0 h :4

5

7

.:3

5 1

1 0

1 0 o:3

, :2

3

2

0

1

A:1

D:1

1

0 P:1 0 c:1

2 1 j:1

2. Listing Program Private Sub MDIForm_QueryUnload(Cancel As Integer, UnloadMode As Integer) End End Sub Private Sub mnhuff_Click() Huffman.Show End Sub Private Sub mnkeluar_Click() End End Sub Private Sub mnshn_Click() Shannon.Show End Sub Private Sub mntentang_Click() frmAbout.Show End Sub

Form Huffman

Option Explicit Private WithEvents Huffman As clsHuffman Private Sub Command1_Click() Dim oldtimer As Single On Error GoTo ErrorHandler 'Store the current timer for later use oldtimer = Timer 'Compress the source file Call Huffman.EncodeFile(Text1(0).Text, Text1(1).Text) 'Update the statistics Label2(3).Caption = Timer - oldtimer & " s " Label2(0).Caption = FileLen(Text1(0).Text) & " bytes" Label2(1).Caption = FileLen(Text1(1).Text) & " bytes" Label2(2).Caption = Int(Val(Label2(1).Caption) / Val(Label2(0).Caption) * 100) & "%" Me.Command2.Enabled = True 'Show a nice dialog to the user Call MsgBox("Compression successful.", vbInformation) Exit Sub ErrorHandler: Call MsgBox("The compression was not successful. Something went terribly wrong." & vbCrLf & vbCrLf & Err.Description, vbExclamation) End Sub Private Sub Command2_Click() Dim FileNr As Integer Dim oldtimer As Single On Error GoTo ErrorHandler 'Store the time for later use oldtimer = Timer 'Uncompress the compressed file Call Huffman.DecodeFile(Text1(1).Text, Text1(2).Text) 'Update decompression statistics Label2(3).Caption = Timer - oldtimer & " s" Label2(0).Caption = FileLen(Text1(1).Text) & " bytes"

Label2(1).Caption = FileLen(Text1(2).Text) & " bytes" Label2(2).Caption = Int(Val(Label2(1).Caption) / Val(Label2(0).Caption) * 100) & "%" 'Show a nice dialog to the user Call MsgBox("Decompression successful.", vbInformation) Exit Sub ErrorHandler: Call MsgBox("The decompression was not successful. Something went terribly wrong." & vbCrLf & vbCrLf & Err.Description, vbExclamation) End Sub Private Sub Command3_Click() Me.CommonDialog1.ShowOpen On Error Resume Next Dim nmfile As String nmfile = Me.CommonDialog1.Filename If nmfile "" Then Me.Text1(0).Text = nmfile Dim l As Integer l = Len(Me.Text1(0).Text) Me.Text1(1).Text = Mid(Me.Text1(0).Text, 1, l - 3) & "huf" Me.Text1(2).Text = Mid(Me.Text1(0).Text, 1, l - 3) & "txt" Me.Command1.Enabled = True End If End Sub Private Sub Form_Load() Set Huffman = New clsHuffman End Sub Private Sub Huffman_Progress(Procent As Integer) Label2(4).Caption = Procent & "%" 'Label2(4).Refresh DoEvents End Sub

Form Shannon Private Sub Command1_Click() Dim FileNr As Single Dim oldtimer As Single oldtimer = Timer CompDecomp = 1 Call Start_Compressor(Compressor_HuffmanShortDict) Dim destfile As String destfile = Me.Text1(1).Text 'FileNr = FreeFile() If (FileExist(destfile)) Then Kill destfile ' Open destfile For Binary As #FileNr ' Put #FileNr, , WorkArray() ' Close #FileNr Call Save_File_As(WorkArray, False) Label2(3).Caption = Timer - oldtimer & " s " Label2(0).Caption = FileLen(Text1(0).Text) & " bytes" Label2(1).Caption = FileLen(Text1(1).Text) & " bytes" Label2(2).Caption = Int(Val(Label2(1).Caption) / Val(Label2(0).Caption) * 100) & "%" Label2(4).Caption = "100%" Call MsgBox("Compression successful.", vbInformation) Me.Command2.Enabled = True End Sub Private Sub Command2_Click() Dim FileNr As Single Dim oldtimer As Single oldtimer = Timer CompDecomp = 2 Call Start_Compressor(Compressor_HuffmanShortDict) Dim destfile As String destfile = Me.Text1(2).Text 'FileNr = FreeFile() If (FileExist(destfile)) Then Kill destfile 'Open destfile For Binary As #FileNr 'Put #FileNr, , WorkArray() 'Close #FileNr Call Save_File_As(WorkArray, False) wak = Timer - oldtimer If wak < 0 Then MsgBox "Decompression Successful" ' wak = CDbl(wak) ^ 2 ' End If

Label2(3).Caption = Timer - oldtimer & " s " Label2(0).Caption = FileLen(Text1(0).Text) & " bytes" Label2(1).Caption = FileLen(Text1(1).Text) & " bytes" Label2(2).Caption = Int(Val(Label2(1).Caption) / Val(Label2(0).Caption) * 100) & "%" End Sub Private Function FileExist(Filename As String) As Boolean On Error GoTo FileDoesNotExist Call FileLen(Filename) FileExist = True Exit Function FileDoesNotExist: FileExist = False End Function Private Sub Command3_Click() Dim OldFileName As String OldFileName = LoadFileName cdlg.DialogTitle = "Select the file you want to explore" cdlg.Filename = "" cdlg.ShowOpen LoadFileName = cdlg.Filename Call load_File(LoadFileName) If LoadFileName = "" Then LoadFileName = OldFileName If LoadFileName = "" Then Exit Sub End If Me.Text1(0).Text = LoadFileName l = Len(LoadFileName) Me.Text1(1).Text = Mid(Me.Text1(0).Text, 1, l - 3) & "shn" Me.Text1(2).Text = Mid(Me.Text1(0).Text, 1, l - 3) & "shn." & Right(Me.Text1(0).Text, 3) Me.Command1.Enabled = True End Sub Private Sub Command4_Click() For Z = LBound(UsedCodecs) To UBound(UsedCodecs) MsgBox UsedCodecs(Z) Next UsedCodecs(0) = 9 For Z = LBound(UsedCodecs) To UBound(UsedCodecs)

MsgBox UsedCodecs(Z) Next End Sub Private Sub Form_Load() CompDecomp = 0 End Sub