This repository has been archived on 2026-03-24. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
TP-PL/TP4.pl
Super_JK 00cec73a26 ajout TP
2022-06-05 15:44:11 +02:00

23 lines
334 B
Prolog

% Ex 5.5
isBST(null).
isBST(T):-
isBST(T,_,_)
isBST(tree(X,null,null),X,X):-
number(X).
isBST(tree(X,L,R),MinL,MaxR):-
isBST(L,MinL,MaxL),
isBST(R,MinR,MaxR),
MaxL=<X,MinR>=X,!.
isBST(tree(X,L,null),Min,X):-
isBST(L,Min,Max),
Max>X,!.
isBST(tree(X,null,R),X,Max):-
isBST(R,Min,Max),
Min<X,!.