My Story, My Life

5hoon's Blog is powered by Tattertools

'encode'에 해당되는 글 1건

  1. 2008/03/04 CSE lecture note... (7)

CSE lecture note...

**Programming 2008/03/04 08:54 by 5hoon
오늘 수업하는데...
지금 말하는 내용은 온라인 렉쳐 노트에 안올라 올꺼라 협박 하시는 교수님 ㅠ
평소때 같은면 Handout 을 보고 끄덕끄덕 거렸겠지만..
끼적끼적 필기를 시작하기 시작했다 -0-

내용은.. 트리구조를 이용해 텍스트 파일을 ASCII 로만 이루어진 텍스트 파일을 압축 하는 것이다.
즉 각 글자는 7bit 씩 쓰게 되는데, 빈도수가 높을수록 bit 를 최소화 하고 빈도수가 낮을수록 bit 를 높게 하여 파일의 용량을 줄이는것..
아래는 필기한 전문.. (트리 그리느냐고 힘좀 썻다 -_-)
A B C D E F
4 2 6 5 8 1

Make each leaf nodes
smaller node to the left.

	+----+
	|  3 |
	+----+
       /      \
 +----+        +----+
 | F 1|        | B 2|
 +----+        +----+

Step 2..
                  +-------+
                  |  16   |
                  +-------+
		 /         \
         0     /             \   1
	     /                 \
       +----+			+----+
       | 11 |			| 15 |
       +----+			+----+
   0  /	     \	1	    0 /       \  1
+----+	      +----+	+----+		+----+
| D 5|	      | C 6|	|  7 |		| E 8|
+----+	      +----+	+----+		+----+
	            0 /       \ 1
		+----+         +----+
		|  3 |         | A 4|
		+----+         +----+
	     0 /      \ 1
	 +----+        +----+
	 | F 1|        | B 2|
	 +----+        +----+
Step 3.

(65)A	101
(66)B	1001
(67)C	01
(68)D	00
(69)E	11
(70)F	1000

BADCAB -> 1001 101 00 01 101 1001
[Prefix Property] - works since we started from the leaf node

Step. 4
Create End of file Char
since the file is saved in bytes the left bit will be filled with 0s
BADCAB will be
10011010 00110110 01______
                    000000
which would translate into BADCABDDD
so create eof char so it ends at the proper position.

.....
AAAABBCCCCCCDDDDDEEEEEEEE
After running the .code file says
68
00
67
01
256	-->	EOF
1000	-->
66
1001
65
101
69
11

결론은..
숙제로 이걸 만들어 내라는것 -0-
프로그램 3개 제출해야 하는듯 -_-
code 를 만들어내는 프로그램 하나
encode 시키는 프로그램 하나
decode 시키는 프로그램 하나..
그래서 10점씩 해서 30점 줄려나;

선생이 테스트 코드를 돌리니 약 45~50% 의 공간이 절약되던...

생각좀 해야겟다. ㅠ
2008/03/04 08:54 2008/03/04 08:54
1 
BLOG main image
My Story, My Life
내가 사는 이야기
by 5hoon

공지사항

카테고리

전체 (107)
**My Life (39)
**Mathematics (14)
**Multimedia (42)
**Programming (4)
**Web Programming (8)

달력

«   2012/02   »
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29      
textcubeDesignMyselfget rss