Example recursive algorithm
function member(item,list)
begin
if list is empty
then return FAIL % terminate
else
if item = first element of list
then return SUCCESS % terminate
else
begin
tail := list with its first item removed;
member(item,tail) % recurse
end
end
Previous slide
Next slide
Back to first slide
View graphic version