I am looking at Range minimum queries.
Wikipedia says :
There are Θ(n²) possible queries for a length-n array.
I do not understand that. Here is an example for an array of size 5.
The following queries are possible :
1 query [0,4]
2 queries [0,3] and [1,4]
3 queries [0,2],[1,3]and [2,4]
4 queries [0,1],[1,2], [2,3] and [3,4]
5 queries [0],[1],[2],[3] and [4]
The total queries possible
[0,4] +
[0,3] + [1,4] +
[0,2] + [1,3] + [2,4] +
[0,1] +[1,2] + [2,3] + [3,4] +
[0] + [1] + [2] + [3] + [4]
---------------------------------
15 queries
But I am expecting N^2 = 25
queries ( where N is array size = 5 )
What am I missing ? Could anyone explain ?