注:文章内容来源于网络,真实性有待确认,请自行甄别。
帮我解释一下这道题目什么意思ProblemStatementWh
发表于:2024-10-24 00:00:00浏览:15次
问题描述:blem Statement
When text is encoded using Huffman codes, each symbol is replaced by a string of 0s and 1s called a bit string representation. The replacement is done in such a way that the bit string representation of a symbol is never the prefix of the bit string repreblem Statement
When text is encoded using Huffman codes, each symbol is replaced by a string of 0s and 1s called a bit string representation. The replacement is done in such a way that the bit string representation of a symbol is never the prefix of the bit string representation of any other symbol. This property allows us to unambiguously decode the encoded text.
You will be given a String archive and a String[] dictionary. The i-th element of dictionary will be the bit string representation of the i-th uppercase letter. Decode archive using dictionary and return the result as a single String.
Definition
Class: HuffmanDecoding
Method: decode
Parameters: String, String[]
Returns: String
Method signature: String decode(String archive, String[] dictionary)
(be sure your methodis public)
Constraints
- archive will contain between 1 and 50 characters, inclusive.
- archive will contain only the characters '0' (zero) and '1' (one).
- dictionary will contain between 1 and 26 elements, inclusive.
- Each element of dictionary will contain between 1 and 50 characters, inclusive.
- Each element of dictionary will contain only the characters '0' (zero) and '1' (one).
- No element of dictionary will be a prefix of any other element of dictionary.
- archive will be decodable using dictionary
Examples
0)
"101101"
{"00","10","01","11"}
Returns: "BDC"
Because there are no elements in dictionary that are prefixes of other elements, only one element of dictionary will be a prefix of archive. In this case, it is the second element ("10") which represents 'B'. The rest of the text can be decoded using the same logic.
1)
"10111010"
{"0","111","10"}
Returns: "CBAC"
Note that elements of dictionary can be of different lengths.
2)
"0001001100100111001"
{"1","0"}
Returns: "BBBABBAABBABBAAABBA"
'1' is replaced by 'A', '0' is replaced by 'B'.
3)
"111011011000100110"
{"010","00","0110","0111","11","100","101"}
Returns: "EGGFAC"
4)
"001101100101100110111101011001011001010"
{"110","011","10","0011","00011","111","00010","0010","010","0000"}
Returns: "DBHABBACAIAIC"
这是一个赫夫曼问题,题目的意思应该是让你设计实现一个名为HuffmanDecoding的类,这个类有一个成员函数decode,这个函数的输入参数有两个,分别是String和String[],而输出为String。
同时为了编程容易现实给出了一些限制,先解释两个例子,然后就对限制有所理解了
"101101"
{"00","10","01","11"}
Returns: "BDC"
输出"101101"和{"00","10","01","11"},后面的四个串是字符的Huffman编码,按字母序分别是A(00),B(10),C(01),D(11)
由于每个编码不能是其他编码的前缀,那么101101就只能切分成10\11\01
这样输出就是对应的BDC
"10111010"
{"0","111","10"}
Returns: "CBAC"
同理,A(0),B(111),C(10),10111010只能切分为10\111\0\10即CBAC
先解释这么多,要下班了,如果还是不懂明天再来补充。
猜你喜欢
- 请指教:关于JAVA的学习本人刚初学JAVA,请大家提供点好的学
- 本人刚初学J,请大家提供点好的学习资料,以及学习中需注意的内容,请高手们多多指教!~~~ 还有本人English不怎么好,对学习JAVA有影响吗?!~~ 先谢谢大家了!~~~
- JAVA编程软件问题。我是一个初学者,现在学习JAVA是运用nt
- 我是一个初学者,现在学习J是运用ntoepad和JDK环境,觉得不太方便,但JBuider不太会用,希望高手推荐一款有操作平台的JAVA编程软件,谢谢!
栏目分类全部>
推荐文章
- 有关java程序员的事在西安有什么公司都招,待遇怎么样.薪水怎么
- 我下载了sdk它是bin文件,怎么打开、安装?谢谢
- 如何看懂java源代码我找了一个开发源码项目cobra,我用ec
- 请指教:关于JAVA的学习本人刚初学JAVA,请大家提供点好的学
- JAVA编程语言有几种啊?这几种哪种是时下的主流?最好的是哪种?
- JAVA编程软件问题。我是一个初学者,现在学习JAVA是运用nt
- JAVA学习中的问题x++和++x这两个运算符到底是怎么运算的?
- 编写jsp网页最好用什么软件现在想学习jsp编写一个基于WEB的
- 小型超市管理系统用java写的代码!急!!!
- jsp网页用户注册时的数据验证制作jsp网页的注册页,想检验用户