This type of question is fair game. It is pretty much equivalent to a
question of the form "Write code to do X", except that X is described
in code rather than in English.
Having said this, the optimization would have to be very pronounced --
it would have to be a major algorithmic improvement. We wouldn't ask
you to make some minor tweaks.
On the other had, time is in short supply. This type of question
requires time to read the supplied code in detail, which takes longer
than English, time to write a response in code, and time for us to
grade code. So, again, the particular case would ahve to be high-
value, or we'd likely have bigger fish to fry.
> and the big-O of the original
> algorithm and the optimized algorithm.
Asking for the Big-O of anything is fair game. It doesn't matter if
you write it or if we write it. It doesn't matter if we ask about one
solution to a problem or more than one.
It is very important to us that you have intuition about the
complexity of algorithms. Big-O is the metric that we've mostly
discussed. So, you should be able to give us a fairly tight Big-O for
an algorithm, determine if a particular Big-O is correct for an
algorithm, and have the ability to let us know when the Big-O isn't
meaningful and why.