c++ - Running mergesort on two linkedLists that are coupled -


i have following problem , see if tell me if i'm on right track approach:

i want "rolling window" kind of computation on 2 linked lists , need them sorted magnitude. if have 1 linked list, writing corresponding mergesort not problem. however, i'm wondering how should go fact have 2 linked lists want have corresponding elements list 1 , list 2 move sort magnitude of list 1. if not entirely clear, mean:

in list 1, want sort magnitude, rearrange pointers. whenever move element "n" in 1 list, however, need move corresponding element "n" in other list same position element other one.

would approach of using mergesort right way go or know better approach? having hard time imagining how go reordering second list while mergesorting first 1 since second list not going sorted magnitude anymore , need individual elements correspond each other. thanks!

marc

just create list of pairs of corresponding elements, , sort list first element of pair.


Comments