Redian新闻
>
Serialize a binary tree to a linked list
avatar
Serialize a binary tree to a linked list# JobHunting - 待字闺中
s*d
1
in order traversal 然后一个一个list.add() 到linked list?
感觉太简单了,有什么问题吗?
avatar
V*g
2
use preoder traversal. That can recover an exact copy of your tree later.
avatar
m*q
3
Preorder traversal result cannot uniquely identify the original tree
structure unless it is a BST, or you insert special node into the list
to represent NULL in the tree.
ihas1337code has a good example of how to make a double linked list
out of a binary tree, and is in-place.

【在 V*******g 的大作中提到】
: use preoder traversal. That can recover an exact copy of your tree later.
avatar
s*d
4
看到了,可以插进去特别标示符,
可以用来deserialize
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。