Home >Backend Development >Python Tutorial >Python implements in-order traversal of a binary tree

Python implements in-order traversal of a binary tree

巴扎黑
巴扎黑Original
2016-12-07 10:55:461844browse

#!/usr/bin/env python

# coding=utf-8

# inorderBL.py

import stdinInput

def inorder(arrays,arraysize,currentP):

    if(2*currentP+1

        inorder(arrays,arraysize,2*currentP+1)

    print arrays[currentP]

    if(2*currentP+2

        inorder(arrays,arraysize,2*currentP+2)


if __name__=='__main__':


    stdinInput.stdinInput()

    inorder(stdinInput.intsortArrays,len(stdinInput.intsortArrays),0)


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn