Question: C++: Code: include using namespace std; struct Node{ char val; Node* next; }; class SLL{ private: Node* headPtr; public: Node* getHeadPtr(){ return headPtr; } void

C++:
Code:
include
struct Node{ char val; Node* next;
};
class SLL{ private:
Node* headPtr;
public: Node* getHeadPtr(){
return headPtr; }
void merge(SLL x){ }
};
Write a function to merge two singly linked lists. This singly linked list is similar to the one we discussed in the lecture. The linked list we use in this question is NOT a circular list. Suppose we have two singly linked lists, the method merge) in SLL class will take one SLL object as argument, merge this list to the current list. The nodes from these two lists should be merged alternatively. For example, we have following two lists. 8. Suppose the first list is in object a, the second list is in object b. After invoke a.merge(b), the list in object a will be the following. x. Please implement the merge0 method listed in the skeleton code. Write down your solution after the skeleton code. To save space, we did not list other methods inside class, such as constructor and destructor etc. However, one method getHeadPtr() is listed. Your solution merge) method will need getHeadPtr(), but not other methods. To simplify discussion, we assume neither list a nor list b can be empty. (20 points)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
