[Prove safety Offer] 57. The next node in the binary tree realized python

Title Description
Given a binary tree and a node which is, find the next node in a preorder traversal order and returns. Note that the node in the tree contains not only the left and right child nodes, the parent node contains a pointer pointing to.

# -*- coding:utf-8 -*-
# class TreeLinkNode:
#     def __init__(self, x):
#         self.val = x
#         self.left = None
#         self.right = None
#         self.next = None
class Solution:
    def GetNext(self, pNode):
        # write code here
Published 116 original articles · won praise 6 · views 6089

Guess you like

Origin blog.csdn.net/weixin_42247922/article/details/104078113