name = 'insertBT/3' slug = 'insert an element into a binary tree' description = '''\
insertBT(X, T, NewT)
: the binary tree NewT
is obtained from T
by inserting the element X
at a certain position. This is the opposite of the predicate deleteBT/3
. Your code should generate all valid solutions.
?- insertBT(2, b(nil,1,nil), T). T = b(b(nil,1,nil),2,nil) ; T = b(nil,2,b(nil,1,nil)) ; T = b(b(nil,2,nil),1,nil) ; T = b(nil,1,b(nil,2,nil)).''' hint = {}