function out = depth(T)
% determines the depth of tree T
if isempty(T)
    out = 0;
else
    temp = depth(T.left);
    out = max(temp, depth(T.right)) + 1;
end;