Question: Using recursion to print a list in reverse order Write a method called printReverse() that takes a list and uses recursion to print the contents
Using recursion to print a list in reverse order
Write a method called printReverse() that takes a list and uses recursion to print the contents of the list in reverse order. The list itself should not be reversed; it must be left in its original form.
Your method should have the following header:
def printReverse(lst, i)
where lst is a reference to the list, and i is an integer parameter that you may use as you see fit. You do not need to code up this method as part of a class a written version of the method itself is all that is required.
your printReverse() method should consider the first element of the list first i.e., the first call to printReverse() should be the one that prints the first element, the second call should be the one that prints the second element, and so on. Half credit will be given for methods that consider the last element first. In either case, your method must be recursive; no methods that employ iteration.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
