PYTHON CODING
Create a method (sortTraversal) for a Binary Search Tree thatprints out the Binary Search Tree in ascending or deceasing order.The order type is an input to the method and can be "ascending" or"descending". The ascending input would return the node values ofthe tree beginning with the smallest and ending with the largest,descending returns the opposite. Discuss method's Big-O notation.Add proper and consistent documentation to identify code sectionsor lines to clearly identify its purpose.Illustrate the performanceof the sortTraversal method
class Node:
# Constructor to create a new node
def __init__(self, data):
self.data = data
self.left = None
self.right = None
class BSTree():
def __init__(self, rootdata):
self.root = Node(rootdata)
def insert(self, data, cur_node):
if data < cur_node.data:
if cur_node.left == None:
cur_node.left = Node(data)
else:
self.insert(data, cur_node.left)
elif data > cur_node.data:
if cur_node.right == None:
cur_node.right = Node(data)
else:
self.insert(data, cur_node.right)
else:
print("Duplicate value!")