Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- initStablo(nil).
- insert(E, nil, s(nil, E, nil)):- !.
- insert(E, s(L, D, R), s(L1, D, R)):-
- E < D,
- insert(E, L, L1),
- !.
- insert(E, s(L, D, R), s(L, D, R1)):-
- E >= D,
- insert(E, R, R1),
- !.
- listToTree([], nil).
- listToTree([ G | R ], S):-
- listToTree(R, S1),
- insert(G, S1, S).
- brCvorova(nil, 0).
- brCvorova(s(L, _, R), N):-
- brCvorova(L, N1),
- brCvorova(R, N2),
- N is N1 + N2 + 1.
- ispisStabla(nil):- !.
- ispisStabla(s(L, E, R)):-
- ispisStabla(L),
- write(E),
- nl,
- ispisStabla(R),
- !.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement