Problem Solving in Data Structures & Algorithms Using Python by Jain Hemant
Author: Jain, Hemant , Date: March 14, 2020
, Views: 235
Example 10.1:
def levelOrderBinaryTree(self, arr):
self.root = self.levelOrderBinaryTreeUtil(arr, 0)
def levelOrderBinaryTreeUtil(self, arr, start):
size = len(arr)
curr = self.Node(arr[start])
left = 2 * start + 1
right = 2 * start + 2
if left < size:
curr.lChild = self.levelOrderBinaryTreeUtil(arr, left)
if right < size:
curr.rChild = self.levelOrderBinaryTreeUtil(arr, right)
return curr
@classmethod
def main(cls, args):
arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
t2 = Tree()
t2.levelOrderBinaryTree(arr)
Copyright Disclaimer:
This site does not store any files on its server. We only index and link
to content provided by other sites. Please contact the content providers
to delete copyright contents if any and email us, we'll remove relevant
links or contents immediately.