Difference between revisions of "POTW 20091022"
(Initial upload of the first POTW)
Revision as of 18:14, 22 October 2009
|In place c-string reversal|
|Question posed by:||Jacob Torrey|
|Source:||AIS Interview Question|
It is your first day of work at Acme Corp, the world-renowned widget company. You have been hired as a software developer in their widgetOS department. Your first task is to implement a function to reverse a C-string in place, however, widgetOS is known for being about as frugal with memory as a good Vermonter is with maple syrup. Below is the skeleton of your function:
void reverse(char * string);
The input string will be a C-string (meaning it is an array characters ending with a '\0' character) and will contain only alphabetic, numeric, and whitespace characters ([a-z][A-Z][0-9]\s\t\r\n).
You must use as little memory as possible (run-time is your secondary concern) and keep in mind of memory usage of any other functions that you call.
Submission and Grading
There will be two winners: the first person to submit a correct answer, and the "best" answer as determined by the problem poser.
You should submit the function, a main function showing it working, a makefile or the compiler arguments to compile your code, and a short write-up describing the memory usage of your function. You should use C or C++. Please submit your solution by emailing it to the problem poser.
Requests for Clarification
Please make all requests for clarification here in the form of: