思考题13-1.b

PERSISTENT-TREE-INSERT(T,z)
	y2 = NIL
	x2 = T2.root = T.root.copy()
	while x2 != NIL
		y2 = x2
		if z.key < x2.key
			x2.left = x2.left.copy()		//NIL.copy()就是NIL本身
			x2 = x2.left
		else
			x2.right = x2.right.copy()
			x2 = x2.right
			
	if y2 == NIL
		T2.root = z
	elseif z.key < y2.key
		y2.left = z
	else 
		y2.right = z

	return T2

  

原文地址:https://www.cnblogs.com/MrWrong/p/7552467.html