Rumah >pembangunan bahagian belakang >Tutorial Python >python实现二叉树的中序遍历
#!/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)