Im trying to implement merge sort with an unsorted linked list but need to use the stl list in C++. I understand how to implement it with a linked list that I would make myself but am confused on how to use the stl list.
For example, how would I got about splitting up the list? Since there are no next pointers to set to null, I don't get how I go about recursively splitting the list. Any help is appreciated!
The conventional approach (for C++) would be to leave the list itself intact.
Instead of splitting the list, have your code work with iterators, and to "split the list", pass a pair of iterators to only part of the list instead of the whole thing.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.