sicp每日一题[2.72]

Exercise 2.72

Consider the encoding procedure that you designed in Exercise 2.68. What is the order of growth in the number of steps needed to encode a symbol? Be sure to include the number of steps needed to search the symbol list at each node encountered. To answer this question in general is difficult. Consider the special case where the relative frequencies of then symbols are as described in Exercise 2.71, and give the order of growth (as a function of n) of the number of steps needed to encode the most frequent and least frequent symbols in the alphabet.


这道题如果只考虑 2.71 的那种情况,最常用的符号永远只需要1位,时间复杂度是 O(1), 最不常用的符号根据 2.71 的图可以看出来,每增加一个符号,所增加的步骤只是常数个,所以时间复杂度应该是 O(n)。

posted @ 2024-11-07 18:43  再思即可  阅读(1)  评论(0编辑  收藏  举报