Late assignments will be penalized 10% per day, and will not be accepted after .
Name, Student Number, Assignment Number, Course Number (T26)
Assignments which are not in an envelope will not be marked
Deposit your envelope in .
Your program must conform to the programming standards. These are described in a separate sheet.
foo- you are expected to devise a recursive algorithm and code
footo use this algorithm. Typically, you'll two choices:
fooso that it calls itself recursively.
fooso that it calls an auxiliary function, say
foo_aux, that is recursive and does all the interesting work. You might choose this option when the initial values for the recursive algorithm are not identical to
foo's initial parameters; or, more generally, when initializations are required before starting the algorithm, or when you need to clean up after it finishes.
For questions 3 and 4, you will be given the binary, not
the source, for an implementation of four list operations:
read_list specified below. You can link these into your
program, but there is no way for you to know how lists are
implemented. The specification tells you all you need to know to use
addupfunction described in class with these arguments:
copy(S,Scopy) that makes a copy of the given stack S.
copymust leave S unchanged - to verify this, write a function called
copy_testthat reads in S, calls
copy, and then prints out S and Scopy.
Use the main program you are given exactly as it is (it calls
tailfunctions provided, write a recursive function
smallest(L) that returns the smallest integer in the given list, L. You may assume L is not empty.
nth(N,L), where N is an integer, L a list. If L contains N (or more) elements, then the function returns the Nth one from the beginning (the first element is L's head). If L contains fewer than N elements, the function returns the last element in L.