首页 > 其他 > 详细

Serialize a Binary Tree or a General Tree

时间:2014-11-03 16:25:40      阅读:178      评论:0      收藏:0      [点我收藏+]

For a binary tree, preorder traversal may be enough.

 

For example, 

    _30_
   /    \   
  10    20
 /     /  \
50    45  35
The result is 

30 10 50 # # # 20 45 # # 35 # #
Using a queue to deserialize it . 

But a for multi-way tree, we could also use an array to serialize it, e.g., 

30 10 20 50 45 35

-1   0    0   1    2   2



Serialize a Binary Tree or a General Tree

原文:http://blog.csdn.net/taoqick/article/details/40741433

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!