I am supposed to show that two algorithms execute identical statements in identical order. One is a tail recursive version of the other. They are written in Eiffel.
tail_rec(x:instance_type):result_type is
local
y:instance_type;
do
if b(x) then
Result :=c(x)
else
y:=d(x);
Result:=tail_rec(y)
end
end
Then the non-tail recursive version.
non_rec(x:instance_type):result_type is
do
from until b(x) loop
x:= d(x)
end;
Result:= c(x)
end
where b(x), c(x), and d(x) are any functions of type BOOLEAN, result_type, and instance_type respectively.
How are these two algorithms similar and how do they execute identical statements in identical order?