这是关于BST在维基百科上发现了一些代码: # 'node' refers to the parent-node in this case
def search_binary_tree(node, key):
if node is None:
return None # key not found
if key < node.key:
return s
我一直在使用一个驱动程序来测试我的一个数据结构(二叉搜索树),我遇到过这个问题。 - 当我向bst插入2个以上的对象时发生 - 我正在尝试做的事情是:我将4个对象插入树中,然后删除2个对象,然后打印出我的find方法,以显示是否不是它找到我要求的对象。例如: public class Driver5 {
public static void main(String[] args) {
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;