Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Fill in code on right in c++ and follow all constraints and directions. 1node compress(node* head) 21/ fill in code here This problem has you
Fill in code on right in c++ and follow all constraints and directions.
1node compress(node* head) 21/ 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 s identified by having a NULL next pointer The linked lists for this lab store string data. Some of the strings in the linked lists repeat, and we'd like to eliminate this repetition. Specifically, if a string repeats, we want to eliminate the duplicates so that the resulting linked list only has one copy of a string in a row. (The string can repeat later in the linked list, as long as some other string occurs in between.) 4 Create a function compress, 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 repetition has been eliminated. The linked list for this problem uses the following class declaration: class node public: string data node next; 3: Notes and Constraints The linked list starting at head contains between 1 and 25 nodes, inclusive. Examples 1. "apple"NULL return "apple"->NULL 2. "apple"->"apple"->NULL return "apple" ->NULL 3. "green"- >"green">blue->"red"->"green"-NULL return "green" >"blue" >"red" >"green NULLStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started