One more actual example:
- We have a time series represented as a single array
value
.
- From that array we calculate a new array with the sums of the consecutive elements,
sum
.
- After removing all empty elements, we get a new array
comp
.
- From that array we count the occurrences of
- each element,
- two consecutive elements
- three consecutive elements
- ...
- N consecutive elements
It's not heavy mathematics - only adding and counting is required - isn't it?
Please tell me what kind of data structure is more convenient for storing the following occurrences/values.
value: -1, 1, -1, -1, 0, 1, 1, -1, 1, 1, 1, 0, ...
sum: -1, 1, , -2, 0, , 2, -1, , , 3, 0, ...
comp: -1, 1, -2, 0, 2, -1, 3, 0, ...
index: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ...
Single element:
element: -2, -1, 0, 1, 2, 3
occurrs: 1, 2, 2, 1, 1, 1
2 consecutive elements:
comp: -1, 1, -2, 0, 2, -1, 3, 0, ...
pairs occurrences
-1, 1 1
1, -2 1
-2, 0 1
0, 2 1
2, -1 1
-1, 3 1
3, 0 1
3 consecutive elements:
comp: -1, 1, -2, 0, 2, -1, 3, 0, ...
pairs occurrences
-1, 1, -2 1
1, -2, 0 1
-2, 0, 2 1
0, 2, -1 1
2, -1, 3 1
-1, 3, 0 1