An n-ary tree is memorised in the following way:
(node (list-subtree-1) (list-subtree-2) ...)
As an example, the tree
A
/ \
B C
/ \
D E
is represented as follows:
(A (B) (C (D) (E)))
Return the number of levels of a tree
The problem is that I am only allowed to use the following functions: null, car, cdr, equal, atom, numberp, cons, cadr, caddr, cond and arithmtic functions.
Could anyone give me a function to return the levels of that kind of tree?
It would be great if you could give me a code that does not use the setq function.
Thanks in advance!
(node (list-subtree-1) (list-subtree-2) ...)
As an example, the tree
A
/ \
B C
/ \
D E
is represented as follows:
(A (B) (C (D) (E)))
Return the number of levels of a tree
The problem is that I am only allowed to use the following functions: null, car, cdr, equal, atom, numberp, cons, cadr, caddr, cond and arithmtic functions.
Could anyone give me a function to return the levels of that kind of tree?
It would be great if you could give me a code that does not use the setq function.
Thanks in advance!