博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
测试图片code
阅读量:6265 次
发布时间:2019-06-22

本文共 1141 字,大约阅读时间需要 3 分钟。

 

def is_full_binary_tree(tree): # This functions returns that is it full binary tree or not?

if tree is None:

return True

def main(): # Main func for testing.

tree = Node(1)

tree.left = Node(2)

tree.right = Node(3)

tree.left.left = Node(4)

tree.left.right = Node(5)

tree.left.right.left = Node(6)

tree.right.left = Node(7)

tree.right.left.left = Node(8)

tree.right.left.left.right = Node(9)

 

print(is_full_binary_tree(tree))

print(depth_of_tree(tree))

print("Tree is: ")

display(tree)

 

if __name__ == '__main__':

main()

 

 

if (tree.left is None) and (tree.right is None):

return True

if (tree.left is not None) and (tree.right is not None):

return (is_full_binary_tree(tree.left) and is_full_binary_

 

def main(): # Main func for testing.

tree = Node(1)

tree.left = Node(2)

tree.right = Node(3)

tree.left.left = Node(4)

tree.left.right = Node(5)

tree.left.right.left = Node(6)

tree.right.left = Node(7)

tree.right.left.left = Node(8)

tree.right.left.left.right = Node(9)

 

print(is_full_binary_tree(tree))

print(depth_of_tree(tree))

print("Tree is: ")

display(tree)

 

if __name__ == '__main__':

main()

 

转载于:https://www.cnblogs.com/binyang/p/10897340.html

你可能感兴趣的文章
一个类有两个方法,其中一个是同步的,另一个是非同步的; 现在又两个线程A和B,请问:当线程A访问此类的同步方法时,线程B是否能访问此类的非同步方法?...
查看>>
[LeetCode] Maximum Product of Word Lengths 单词长度的最大积
查看>>
socket通信中select函数的使用和解释
查看>>
JAVA Map集合类简介
查看>>
c++实现gray code(格雷码)
查看>>
Spark1.4.1 编译与安装
查看>>
epub显示特殊字体
查看>>
JDK各个版本的新特性jdk1.5-jdk8
查看>>
ZOJ 3529 A Game Between Alice and Bob(博弈论-sg函数)
查看>>
zoj 2822 Sum of Different Primes (01背包)
查看>>
Directx11学习笔记【三】 第一个D3D11程序
查看>>
UVa 11292 - Dragon of Loowater
查看>>
【Android】3.15 短串分享功能
查看>>
火星人乘坐核动力飞船回故乡
查看>>
怎么限制Google自己主动调整字体大小
查看>>
iOS Runtime原理及使用
查看>>
asp.net将内容导出到Excel,Table表格数据(html)导出EXCEL
查看>>
mysql中间件研究(Atlas,cobar,TDDL)
查看>>
Sublime text3 插件LiveReload 实现实时预览
查看>>
JS实现电子时钟
查看>>