美文网首页
331. Verify Preorder Serializati

331. Verify Preorder Serializati

作者: 我是你的果果呀 | 来源:发表于2016-12-27 07:03 被阅读0次

One way to serialize a binary tree is to use pre-order traversal. When we encounter a non-null node, we record the node's value. If it is a null node, we record using a sentinel value such as#.

    _9_
     /  \
   3     2
  / \      / \
 4  1   #   6
 / \  / \     / \
# # # #   # #
Example 1:  "9,3,4,#,#,1,#,#,2,#,6,#,#" Return  true
Example 2: "1,#" Return false

不为空的节点 ,有2个出点, 1个入点, 为空的有0个出点, 1个入点。

相关文章

网友评论

      本文标题:331. Verify Preorder Serializati

      本文链接:https://www.haomeiwen.com/subject/causvttx.html