Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defun dfs (lista n max el)
- (cond
- ;Ako e do max dlabocina, prekini
- ((= n max) NIL)
- ; Jazol
- ((and (eq (cadr lista) NIL) (eq (caddr lista) NIL)) (eq (car lista) el))
- ;Ako ima levo dete
- ((and (listp (cadr lista)) (eq (caddr lista) NIL)) (dfs (cadr lista) (+ n 1) max el))
- ;Ako ima desno dete
- ((and (listp (caddr lista)) (eq (cadr lista) NIL)) (dfs (caddr lista)(+ n 1) max el))
- ;Ako ima dve deca
- ((and (listp (cadr lista)) (listp (caddr lista))) (OR (dfs (cadr lista) (+ n 1) max el) (dfs (caddr lista) (+ n 1) max el)))
- )
- )
- ;(inorder LISTA POCETEN_BROJAC=0 MAX_DLABOCINA ELEMENT_STO_SE_BARA)
- (inorder '(1 (2 (3 NIL NIL)(4 NIL NIL))(5 (6 NIL NIL)(7 NIL NIL))) 0 3 4)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement