I'm not sure this is oh-so elegant, but using an array:

int offset = 1003;
ranges[1768 - offset]. Set all values in array to 0.

Iterate through the list, and mark each ranges[list value - offset]
with a 1.
When you've gone through the full list, go back through the ranges[]
and anything with a zero
represents an unused range list number, after you add back in the
offset.

Ranges which begin at < offset, are equal to the offset. When the
range extends beyond the highest range of
the range list you're set up for, again, cut it off to avoid running
out of bounds in the ranges array.

When you start a new listed range, ignore the nested feature, and just
have it initialize the ranges array elements listed, with a 1.
You can do this more elegantly with an array for each of the ranges,
and have the final free ranges "fall down" through them, but
that uses a lot more memory, and will not be as fast, either.

Trying to code up the nested handling portion, for each item on the
list, I see as a quagmire - and unnecessary to cross. If what you
want is the free ranges listed, this will give it to you, and who care
what item below the item in question, is nested within what other
item(s)?



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/algogeeks
-~----------~----~----~----~------~----~------~--~---

Reply via email to