Explore BrainMass
Share

Explore BrainMass

    Function Trace

    This content was COPIED from BrainMass.com - View the original, and get the already-completed solution here!

    Trace the function f() and indicate its action on the list object alist.

    template <typename T>
    void f(list<T>& alist, list<T>::iterator iter)
    {
    if(iter != alist.end())
    {
    alist.push_front(*iter);
    alist.erase(iter++);
    f(alist.iter);
    }
    }

    © BrainMass Inc. brainmass.com October 9, 2019, 11:54 pm ad1c9bdddf
    https://brainmass.com/computer-science/program-execution/function-trace-271847

    Solution Preview

    The function f() is to reverse an list.
    For example, suppose alist = {1, 2, 3, 4, 5}
    At the beginning, iter points to 1.
    Then in the function f(), it does ...

    Solution Summary

    The expert examines a function trace.

    $2.19