Generally what kind of algorithm is used to solve when dealing with overlapping data sets .In the below problem set, we can see that region (point 2 to point 3) is common to both statement A and statement B.Problem SetStatement A : Point 1 to 3 --> Speed is 30kmphStatement B : Point 2 to 5 --> Speed is 50kmphGoal is to reorganize the data by splitting the common data ranges and calculating the averages and show them as below.Expected result :1 to 2 -> 30 kmph2 to 3 -> (30 + 50)/2 -> 40 kmph3 to 5 -> 50 kmph
What would be an appropriate algorithm to solve mixed data range problems
algorithms
Keep segments in sorted order (list, binary tree, whatever...)When adding a new segment, search list, binary tree, whatever to see if it either end of the new segment overlaps an existing segment. If it does, remove/split into new set of segments according to your combining rule (in your example, averaging the overlapping parts).I don't think there is a standard approach as too much will depend upon the actual application. (Mixing sound according to cues, temporal logic, etc.)For small problems, a sorted linked list of non-overlapping segments would suffice. There are lots of interesting edge cases to be tested, whatever your implementation.