class Node:
'''represents a new node in the BST'''
def __init__(self,key):
self.key=key
self.disconnect()
def disconnect(self):
self.left=None;
self.right=None;
self.parent=None;
def __str__(self):
return 'node with kay %s'%self.key
class BST:
def __init__(self):
self.root=None
def insert(self,t):
'''inserts a new element into the tree'''
self.find_place(self.root,t)
def find_place(self,node,key):
finds the right place of the element recursively
if node is None:
node=Node(key)
print node
else:
if node.key > key:
find_place(node.left,key)
else:
find_place(node.right,key)
def test():
'''function to test if the BST is working correctly'''
मैं एक द्विआधारी खोज वृक्ष लागू करने के लिए ऊपर दिए गए कोड लिखा था लेकिन डालने विधि काम नहीं कर रहा अपेक्षा के अनुरूप, तो यह और भी जड़ तत्व जोड़ने के लिए विफल रहता है। मैं कारण समझने के नहीं कर सकते।













