Binary Tree Traversals Problem Description A binary tree is a finite set of vertices that is either empty or consists of a root r and two disjoint binary trees called the left and right subtrees. There are three most important ways in which the verti
#coding:utf-8 class node(): def __init__(self,k=None,l=None,r=None): self.key=k; self.left=l; self.right=r; def create(root): a=input('enter a key:'); if a is '#': root=None; else: root=node(k=a); root.left=create(root.left); root.right=create(root.r
tree.go package tree import ( "fmt" ) type TreeNode struct { ID int Val int Left *TreeNode Right *TreeNode } func PreOrder(root *TreeNode) { if root != nil { fmt.Printf("%d ", root.Val) PreOrder(root.Left) PreOrder(root.Right) } } func