《Cracking the Coding Interview》——第17章:普通题——题目10
2014-04-28 23:59
513 查看
2014-04-28 23:54
题目:XML文件的冗余度很大,主要在于尖括号里的字段名。按照书上给定的方式进行压缩。
解法:这题我居然忘做了,只写了一句话的注解。用python能够相对方便地实现,因为有直接的XML工具可以调用。书上的那种要求应该是符合前序遍历规则。
代码:
题目:XML文件的冗余度很大,主要在于尖括号里的字段名。按照书上给定的方式进行压缩。
解法:这题我居然忘做了,只写了一句话的注解。用python能够相对方便地实现,因为有直接的XML工具可以调用。书上的那种要求应该是符合前序遍历规则。
代码:
# 17.10 Parse an XML file, and try to save some space by mapping every item name to an integer index. # Answer: # Preordere traversal of an element tree, maybe ElementTree will be a good tool.
相关文章推荐
- 《Cracking the Coding Interview》——第17章:普通题——题目1
- 《Cracking the Coding Interview》——第17章:普通题——题目2
- 《Cracking the Coding Interview》——第17章:普通题——题目9
- 《Cracking the Coding Interview》——第17章:普通题——题目3
- 《Cracking the Coding Interview》——第17章:普通题——题目11
- 《Cracking the Coding Interview》——第17章:普通题——题目12
- 《Cracking the Coding Interview》——第17章:普通题——题目13
- 《Cracking the Coding Interview》——第17章:普通题——题目4
- 《Cracking the Coding Interview》——第17章:普通题——题目14
- 《Cracking the Coding Interview》——第17章:普通题——题目5
- 《Cracking the Coding Interview》——第17章:普通题——题目6
- 《Cracking the Coding Interview》——第17章:普通题——题目7
- 《Cracking the Coding Interview》——第17章:普通题——题目8
- 《Cracking the Coding Interview》——第18章:难题——题目10
- 《Cracking the Coding Interview》——第13章:C和C++——题目10
- 《Cracking the Coding Interview》——第8章:面向对象设计——题目10
- 《Cracking the Coding Interview》——第9章:递归和动态规划——题目10
- 《Cracking the Coding Interview》——第18章:难题——题目8
- 《Cracking the Coding Interview》——第1章:数组和字符串——题目5
- 《Cracking the Coding Interview》——第3章:栈和队列——题目3