Question: Fill in code on right in c++ and follow all constraints and directions. 1 hode expand (node* head) // fill in code here This problem

Fill in code on right in c++ and follow all constraints and directions.
1 hode expand (node* head) // fill in code here This problem has you modify a linked lists composed of node objects chained together via node pointers. Each node has a next pointer which points to the next node in the chain. The last node is identified by having a NULL next pointer 4 The linked lists for this lab store string data. Some of the strings in the linked lists repeat, some do not, but we'd like all strings to repeat at least once. Specifically, if a string does not repeat, we want to insert a copy of the string so that there are two of the string in a row. If the string already repeats, we do nothing. Note that a string may re-occur later in a linked list; this does not count as a repetition for our purposes Create a function expand, which takes in a pointer to the head of the linked list, and returns a pointer to the head of a linked list in which all strings repeat following the rules described above The linked lists for this problem use the following class declaration: class node f public: string data; node next; J: Notes and Constraints . The linked list starting at head contains between 1 and 25 nodes, inclusive Examples apple" ->NULL return "apple" ->"apple"- >NULL 2. "apple" - >"apple"->NULL return "apple"->"apple" ->NULL 3."green"-"green"->"blue" ->"red"->"green"- NULL return "green"->"green"->"blue" ->"blue"->"red" ->red" ->"green" ->"green" - >NULL
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
