Is this a trick question? If array > array[i-1] for all i, then surely array > array[i-k] for all positive values of k. So you can ignore the inner loop. Or am I missig something?

Is this a trick question? If array > array[i-1] for all i, then surely array > array[i-k] for all positive values of k. So you can ignore the inner loop. Or am I missig something?

Well, I think you may be making an assumption of the value of any given element of the array. array may point to a value 7 where array may point to a value of 77.

Search linearly through an array of size n and for each element check whether array>array[i-k] for all k=1,2,...n/5.

I made no assumption about the data, I was just exploring the logical consequences of the problem statement.
In the case you give, the boolean is false, no further processing is required. You will hit this condition (if it is the case) in a single pass - hence O(n).
It's only interesting if the boolean is true, hence you need to keep looking. In that case the recursive analysis I posted suggests you do not need the nested loop, a single loop is sufficient, hence it runs in O(n).

I made no assumption about the data, I was just exploring the logical consequences of the problem statement.
In the case you give, the boolean is false, no further processing is required. You will hit this condition (if it is the case) in a single pass - hence O(n).
It's only interesting if the boolean is true, hence you need to keep looking. In that case the recursive analysis I posted suggests you do not need the nested loop, a single loop is sufficient, hence it runs in O(n).

Actually I made a mistaken assumption that i ∀ 0 - n. (Or i represents a range of all indices of the array).
He didn't say anything to that effect. If i is one value, then the case is trivial. If i is meant to specify a range of values, then it is impossible to do in O(n).

Hi, as I was told that my code doesn’t scale well at all, I thought perhaps I’d try to get a better understanding of interfaces/abstract classes and classes and the relationship between them.
I don’t want at this stage work on a big separate project as I've already got plenty ...

Hey, so I wanna ask how I need to create a method who will remove word if in that word is 2 same chars. Example: "Potato" in this word there is a 2 "o" chars so this word will need to be removed. "Forum" in this word there is no ...

Hi I'm having a problem implementing a mini shopping cart drop down in the header to show the user all the products they have in their shopping cart. It seems the only solution for this is Ajax, and I've looked all over and can't find anything that I could possibly ...