summaryrefslogtreecommitdiff
path: root/prolog/problems/trees/insertbt_3/en.py
blob: 08eb2cd5119ed98213eb8b08bfbf3717be8f60c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# coding=utf-8

name = 'insertBT/3'
slug = 'insert an element into a binary tree'

description = '''\
<p><code>insertBT(X, T, NewT)</code>: the binary tree <code>NewT</code> is obtained from <code>T</code> by inserting the element <code>X</code> at a certain position. This is the opposite of the predicate <code>deleteBT/3</code>. Your code should generate all valid solutions.</p>
<pre>
  ?- 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)).
</pre>'''

hint = {}