adrianmak
asked on
count the height of a tree
I have a function that count the height of a tree
function countheight(root:tree):int eger;
var left, right:integer;
begin
if root=nil then countheight:=0
else
begin
left:=countheight(root^.le ft);
right:=countheight(root^.r ight);
if left>right then countheight:=1+left
else countheight:=1+right
end;
end;
I don't know the IF condition so it can calculate the height of a tree
Please explain in details
function countheight(root:tree):int
var left, right:integer;
begin
if root=nil then countheight:=0
else
begin
left:=countheight(root^.le
right:=countheight(root^.r
if left>right then countheight:=1+left
else countheight:=1+right
end;
end;
I don't know the IF condition so it can calculate the height of a tree
Please explain in details
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.