Input: C, P. C is the set of cached data for a stock s and formalized as C = {ci | i ∈ [0, n)}, where i is integer. Assuming that pi is the value of ci, P is formalized as P = {pi | i ∈ [0, n)}, where i is integer. |
Output: new value of C and P after merging. |
|
1. |
O ← P |
2. |
WHILE O ≠ Ø DO |
3. |
pk = max{pi | pi ∈ O}, O←O–{pk} |
4. |
Q←O |
5. |
WHILE Q ≠ Ø DO |
6. |
qj = max {qi | qi ∈ Q}, Q←Q–{qj} |
7. |
IF ck and cj overlap |
8. |
merging ck and cj and the new data is cl |
9. |
IF pi ≥ pk |
10 |
C←C–{ck, cj}+{cl} |
11 |
P←P–{pk, pj}+{pl} |
12. |
RETURN CDMO (C, P) // Iteratively call Algorithm 1 |
13. |
END WHILE |
14. |
END WHILE |
15. |
RETURN C, P |