Given a sequence of n numbers, {a 1 , a 2 , a 3 , ..., a nsub>}. Create a data structure so that the following operations are performed during polyling.
Inverse (i, j):
Flip all the elements in the range from i to j, as shown below:
Original sequence: <... a i-1 , i , a i + 1 , ..., a j-1 , a j , a j + 1 , ...>
Sequence after swap: <... a i-1 , j , a j-1 , ..., a i-1 , i , a j + 1 , ...>
Report (i):
Report the i-th element in the sequence, i.e. i .
Here poly-logn means some degree of log n. how log (n) Β· log (n) may be acceptable.
[Note: thanks prof. Baswan for asking this question.]
ramshankar