CSL102: Introduction to Computer Science
II semester 2004-05
Assignment: Reversing an Integer using only integer operations
Develop an algorithm
to reverse the digits of an integer (given in base 10).
- You are allowed to use only functions on integers in your algorithm.
- The following examples should guide you on some special cases:
- First develop the method and try to give a proof that it is correct.
- Translate your method into SML and write an SML program to do the same.
- You are not allowed to change any of the names given in
the signature. You are not even allowed to change upper-case letters
to lower-case letters or vice-versa.
- You may define any new functions you like in the structure besides those
mentioned in the signature.
- Your program should work with the given signature.
- You need to think of the most efficient way of implementing the
various functions given in the signature so that the function results
satisfy their definitions and properties.
- Since the evaluator is going to look at your source code before
evaluating it, you must explain your algorithms in the form of ML
comments, so that the evaluator can understand what you have implemented.
- Do not add any more decorations or functions or
user-interfaces in order to impress the evaluator of the program.
Nobody is going to be impressed by it.
- There is a serious penalty for copying. If it is felt that there is too
much similarity in the code between any two persons, then both are going
to be penalized equally. So please set permissions on your directories,
so that others cannot copy your programs.