python - The creation of a binary treeBinary Tree Creati -


i have problem 1 exercise based on binary tree creation. try explain.

a task is:

there array created walking binary tree preorder procedure. example have following output of preorder procedure : 2 1 0 0 3 0 0. 2 root of balanced binary tree, 1 left child, 2 right child. node 1 , 2 leaves, children 0 0 , 0 0.

this output made preorder procedure looks following:

printpreorder(root):  if root:       print(root.key)       printpreorder(root.left)       printpreorder(root.right) 

i have class tree (python)

class(tree):      def __init__(self, key):          self.key = key          self.left = none          self.right = none 

using output of preorder procedure need create array objects nodes of binary tree input in preorder procedure. how make maybe recursion, maybe not. each property of tree objects have pointer on other objects.


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -