Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spatio Temporal Database Management International Workshop Stdbm 99 Edinburgh Scotland September 10 11 1999 Proceedings Lncs 1678

Authors: Michael H. Bohlen ,Christian S. Jensen ,Michel O. Scholl

1999th Edition

3540664017, 978-3540664017

More Books

Students also viewed these Databases questions