Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Akshay Mandania
- //Doesnt work properly
- //Idea is there but my laptop battery was going to die and all my notes where on here
- //My plan was to create 2 linked lists and uses pointers to compare data between both lists and then remove greater value off the list and push it onto list 3. and then keep going. I was going to build an insertion sort for list3.
- #include <iostream>
- using namespace std;
- class SortingLists {
- public:
- List list1;
- List list2;
- List list3;
- void MergeLists(List list1, List list2) {
- Node *head;
- if (list1->data < list2->data) {
- head = list1;
- } else {
- head = list2;
- list2 = list1;
- list1 = head;
- }
- while(list1->next != NULL) {
- if (list1->next->data > list2->data) {
- Node tmp = list1->next;
- list1->next = list2;
- list2 = tmp;
- }
- list1 = list1->next;
- }
- list1->next = list2;
- list3 = head;
- }
- };
- int main()
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement