由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 问一道算法题
相关主题
F家phone interview的一道题How to serialize and deserialize
如何 serialization 和deserialization hash table ?面经+求助
Serialize a binary tree to a linked list请教一下超大图的存储问题
Google第二次电面Serialization/Deserialization of a Binary Tree
问道Binary tree serialization/de-serialization的题刚拿到A公司的offer,呈上面经
Deserialize in-order array to a minimum height binary tree.弱弱的问关于二叉树的问题
A question about how to uniquely represent a binary treeA家面经, offer, 请教Negotiation
求个java版本的binary tree serialization和deserializationPhone interview question
相关话题的讨论汇总
话题: traversal话题: node话题: tree话题: ary
进入JobHunting版参与讨论
1 (共1页)
x*********s
发帖数: 2604
1
how to serialize and deserialize a n ary tree?
g*****x
发帖数: 799
2
如果是binary的话inorder+preorder或inorder+postorder
n-nary存(node, parent) pair貌似可以,不知道有什么更好的方法
P********l
发帖数: 452
p******r
发帖数: 2999
4
序列化成前序和中序

【在 x*********s 的大作中提到】
: how to serialize and deserialize a n ary tree?
g*****x
发帖数: 799
5
LZ问的是N叉树,不一定能用中序遍历
s*********l
发帖数: 103
6

注意二叉树不同节点内容可能有重复,比如
inorder: [1,1,1,1,1,1,1]
preorder: [1,1,1,1,1,1,1]

【在 g*****x 的大作中提到】
: 如果是binary的话inorder+preorder或inorder+postorder
: n-nary存(node, parent) pair貌似可以,不知道有什么更好的方法

j********x
发帖数: 2330
7
Do a pre-order traversal, after the traversing of a subtree, record the size
of the subtree with that node. Got some thing like this:
serialized_node,size_of_the_sub_tree_rooted_at_this_node,node,size
A recursive deserialization process is easy to get.
As for two traversal, I dont get it. Meaning to store two arrays of node
keys? But a serious problem is that we need to traverse twice of the tree.
Not good.
P********l
发帖数: 452
8

size
More explanation on the "serialized_node"? Seems you saved redundant info.
No. Only one traversal can obtain both arrays.
The problem of the method is in deserialization. One traversal needs to look
up ids in another one to recover the tree.
I don't think the two traversal method is practical for serialization.

【在 j********x 的大作中提到】
: Do a pre-order traversal, after the traversing of a subtree, record the size
: of the subtree with that node. Got some thing like this:
: serialized_node,size_of_the_sub_tree_rooted_at_this_node,node,size
: A recursive deserialization process is easy to get.
: As for two traversal, I dont get it. Meaning to store two arrays of node
: keys? But a serious problem is that we need to traverse twice of the tree.
: Not good.

1 (共1页)
进入JobHunting版参与讨论
相关主题
Phone interview question问道Binary tree serialization/de-serialization的题
怎样serialize binary tree 比较好?Deserialize in-order array to a minimum height binary tree.
请教一道leetcode的题目A question about how to uniquely represent a binary tree
贡献最近面的T家电面一题,顺便求个bless求个java版本的binary tree serialization和deserialization
F家phone interview的一道题How to serialize and deserialize
如何 serialization 和deserialization hash table ?面经+求助
Serialize a binary tree to a linked list请教一下超大图的存储问题
Google第二次电面Serialization/Deserialization of a Binary Tree
相关话题的讨论汇总
话题: traversal话题: node话题: tree话题: ary