Write a C++ program which takes one or more integers on the command line, and for each one,
To generate random numbers, look up the
srand functions in
I suggest writing a
clone function or method, producing
a list just like the original, but not sharing any memory with it, so
that if one is mutated, the other is unaffected.
smallest are extremely
similar functions, I'd like you to do them two different ways: one
with recursion, and the other with a loop. (The recursive version may
crash with a stack overflow if you give it too large an array,
because C++ doesn't do tail-call optimization. If so, figure out
approximately how large an array the recursive version can handle on
your computer, and tell me this limit when you turn in the homework.)
For the "reverse" step, I don't want you to just print the list in reverse order; I want you to actually reverse the list, and then call the same function you used before to print the list.
Use whatever sorting algorithm you like; it
would be interesting to have different students use different
sorting algorithms. (I did insertion, selection, and merge sorts.)
For timing, look up the
I recommend writing this in several source files.
Turn in all your source code files, all your header files,