Is there a function f (possibly real-valued) such that f is
- O(n2),
- not o(n2),
- Ω(n),
- not ω(n), and
- nondecreasing?
(That is, f is big-O of n2, not little-o of n2, big-Omega of n, not little-omega of n, and nondecreasing).
Is there a function f (possibly real-valued) such that f is
(That is, f is big-O of n2, not little-o of n2, big-Omega of n, not little-omega of n, and nondecreasing).
Essentially, you’re looking for a function that
Here’s one way to do this. Imagine drawing out the curves n and n2. Now, draw your function f by first following the curve n2 for some period of time, then drawing a horizontal line until you hit the curve n and tracing along that curve for a bit, then jump vertically to n2 and follow that curve for a bit, repeating this process out to infinity. That is, we're looking for something like this:

The net effect of this is the following:
The n2 curve is a tight asymptotic upper bound on f. The curve infinitely often takes on the value of n2 and never exceeds n2. That makes f(n) = O(n2) but not o(n2).
The n curve is a tight asymptotic lower bound on f. The curve infinitely often takes on the value of n but never drops below n. That makes f(n) = Ω(n) but not ω(n).
The function is nondecreasing.
The tricky part here is finding an exact formula for such a curve. We can do this using a recursive definition. The basic idea is the following:
This gives us the following recursive definition:

Here’s the first few values taken on by this function:
0, 1, 4, 4, 4, 25, 25, 25, ..., 25, 676, 676, ...
This was a fun one to work through - hope this helps!