psf/black code formatting (#1277)

This commit is contained in:
William Zhang
2019-10-05 01:14:13 -04:00
committed by Christian Clauss
parent 07f04a2e55
commit 9eac17a408
291 changed files with 6014 additions and 4571 deletions

View File

@ -1,12 +1,13 @@
class Node: # This is the Class Node with constructor that contains data variable to type data and left,right pointers.
class Node: # This is the Class Node with constructor that contains data variable to type data and left,right pointers.
def __init__(self, data):
self.data = data
self.left = None
self.right = None
def display(tree): #In Order traversal of the tree
if tree is None:
def display(tree): # In Order traversal of the tree
if tree is None:
return
if tree.left is not None:
@ -19,7 +20,10 @@ def display(tree): #In Order traversal of the tree
return
def depth_of_tree(tree): #This is the recursive function to find the depth of binary tree.
def depth_of_tree(
tree
): # This is the recursive function to find the depth of binary tree.
if tree is None:
return 0
else:
@ -31,18 +35,20 @@ def depth_of_tree(tree): #This is the recursive function to find the depth of bi
return 1 + depth_r_tree
def is_full_binary_tree(tree): # This functions returns that is it full binary tree or not?
def is_full_binary_tree(
tree
): # This functions returns that is it full binary tree or not?
if tree is None:
return True
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_tree(tree.right))
return is_full_binary_tree(tree.left) and is_full_binary_tree(tree.right)
else:
return False
def main(): # Main func for testing.
def main(): # Main func for testing.
tree = Node(1)
tree.left = Node(2)
tree.right = Node(3)
@ -59,5 +65,5 @@ def main(): # Main func for testing.
display(tree)
if __name__ == '__main__':
if __name__ == "__main__":
main()