In view of the long encoding time and the low coding efficiency, this paper presents a code optimization algorithm based on the code length. By set uping the attribute of increasing or decreasing and coding sequence of symbols, the algorithm looks on the infix codes as the goal and constructs four different coding algorithms. In view of the fact that large number of calculating doesn' t exist in the Shannon code algorithm, the coding time can be greatly reduced. Through the analysis of the principle of the algorithm, the algorithm is optimized...