Advertisement
Guest User

Untitled

a guest
Jan 24th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Prolog 0.38 KB | None | 0 0
  1. checkIfBST(t(_, nil, nil)).
  2.  
  3. checkIfBST(t(Key, t(LKey, LLT, LRT), nil)):-
  4.     Key > LKey,
  5.     checkIfBST(t(LKey, LLT, LRT)).
  6.  
  7. checkIfBST(t(Key, t(RKey, RLT, RRT))):-
  8.     Key > RKey,
  9.     checkIfBST(t(RKey, RLT, RRT)).
  10.  
  11. checkIfBST(t(Key, t(LKey, LLT, LRT), t(RKey, RLT, RRT))):-
  12.     Key > LKey,
  13.     Key < RKey,
  14.     checkIfBST(t(LKey, LLT, LRT)),
  15.     checkIfBST(t(RKey, RLT, RRT)).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement