ittiam

June 6th, 2009, 01:53 AM

I would like to compare each element of a tuple with all the elements of another tuple in C. For example

Tuple 1 [20,30] [70,90].[100,150] ......

Tuple 2 [10,40] [80,120] [220,300] ......

I need to verify whether any of the element in tuple 1 fits into any of the element in tuple 2. Above example, [20,30] of tuple 1 fits in [10,40] of tuple 2. Also I will have to update tuple 1 if there are any overlapping. Element 2 of tuple 1, [70,90] on comparison with [80,120] should be updated to [70,120]. Get the gist?

Now that the question is stated, my problem is efficiency. The number of if checks is just too much and any suggestions for an efficient implementation will be helpful.

The programming language is strictly C. No python.

Tuple 1 [20,30] [70,90].[100,150] ......

Tuple 2 [10,40] [80,120] [220,300] ......

I need to verify whether any of the element in tuple 1 fits into any of the element in tuple 2. Above example, [20,30] of tuple 1 fits in [10,40] of tuple 2. Also I will have to update tuple 1 if there are any overlapping. Element 2 of tuple 1, [70,90] on comparison with [80,120] should be updated to [70,120]. Get the gist?

Now that the question is stated, my problem is efficiency. The number of if checks is just too much and any suggestions for an efficient implementation will be helpful.

The programming language is strictly C. No python.