# coding=utf-8 name = 'deleteBT/3' slug = 'delete an element from a binary tree' description = '''\
deleteBT(X, T, NewT)
: the binary tree NewT
is obtained from T
by deleting one occurence of the element X
. If X
is not a leaf node, the root of one of its subtrees is moved up. Your code should generate all valid solutions.
?- deleteBT(1, b(b(b(nil,4,nil),2,b(nil,6,nil)),1,b(nil,3,b(nil,5,nil))), T). T = b(b(nil,4,b(nil,6,nil)),2,b(nil,3,b(nil,5,nil))) ; T = b(b(b(nil,4,nil),6,nil),2,b(nil,3,b(nil,5,nil))) ; T = b(b(b(nil,4,nil),2,b(nil,6,nil)),3,b(nil,5,nil)).''' hint = {}