Re:Data structures and algorithms problems in C++ using STL
by mkingston on Friday March 10, 2017 @10:53AM
(#13839500)
Suppose you have a type A ('0' in the original description) and a type B ('1' in the original description). Suppose any instance of A < any instance of B, but any given instance of A is not necessarily even comparable to another instance of A. Similarly any instance of B is not necessarily comparable to another instance of B. Now stably sort an array containing instances of A and B.
[ Parent
| on HN ]
Re:Data structures and algorithms problems in C++ using STL
by openasocket on Friday March 10, 2017 @11:18AM
(#13839686)
OK, now I see why this is hard, thanks. Now I'm gonna spend the next few days mulling over this problem :)
I noticed the problem is relatively easy if you're dealing with a linked list instead of an array, because you can easily move elements around. If there's some way to amortize that in the array case...