On Jan 29, 2008 12:11 PM, Tolkin, Steve <[EMAIL PROTECTED]> wrote:
> I want to reconstruct the underlying list.  In other words the order of
> the elements agrees in all the lists, but there is no sort condition.
>
> Example:
> List 1: dog, cat, mouse
> List 2: dog, shark, mouse, elephant
>
> There are 2 possible outputs, and I do not care which one I get.
>
> The reason that I have not just coded this up is that it seems it
> require an unbounded amount of look ahead.  Also, when there are more
> than 2 lists, I think I need to read from all of them before making a
> decision about which element can be safely output.

What comes to mind is indexing all of the words on the maximum depth
they occur in any list.  Then you output all the elements of max_depth
1 (dog), all the elements of max_depth 2 (cat, shark), max_depth 3
(mouse), max_depth 4 (elephant).

You still have to read all the lists at least once, though.

David
 
_______________________________________________
Boston-pm mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to