Difference between revisions of "POTW 20091022"

From CSLabsWiki
Jump to: navigation, search
(Initial upload of the first POTW)
 
(Way to go Sam!)
Line 6: Line 6:
 
| source = AIS Interview Question
 
| source = AIS Interview Question
 
| duedate = 2009-10-29
 
| duedate = 2009-10-29
 +
| firstanswer = Sam Payson
 
|}}
 
|}}
  

Revision as of 15:31, 23 October 2009

Problem Statement

In place c-string reversal
Question posed by: Jacob Torrey
Source: AIS Interview Question
Date Posed: 2009-10-22
First Answered By: Sam Payson


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:

Q: Question