Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

File supplied.o contains code that can build, display, and destroy a linear lineked list . For this lab, you will need to write the following

File supplied.o contains code that can build, display, and destroy a linear lineked list.

For this lab, you will need to write the following two functions in list.cpp, and add function prototypes for them to list.h. The solutions need to be recursive.

  • void duplicate(node *& newHead) const

recursively create a copy of the source list. newhead is the head of the destination list.

  • int removeTwo()

recursively remove all the 2s from the list

//list.h #include #include #include using namespace std;

struct node { int data; //some questions are a char * data; node * next; };

class list { public: //These functions are already written for you list(); //supplied ~list(); //supplied void build(); //supplied void display(); //supplied /* *****************YOUR TURN! ******************************** */ //Write your function prototype here:

private: //notice there is both a head and a tail! node * head; node * tail; };

// main.cpp

#include "list.h"

int main() { list object; object.build(); //builds a LLL object.display(); //displays the LLL

//PLEASE PUT YOUR CODE HERE to call the functions

object.display(); //displays the LLL again! return 0; }

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

Refactoring Databases Evolutionary Database Design

Authors: Scott Ambler, Pramod Sadalage

1st Edition

0321774515, 978-0321774514

More Books

Students also viewed these Databases questions

Question

What is the basis for Security Concerns in Cloud Computing?

Answered: 1 week ago

Question

Describe the three main Cloud Computing Environments.

Answered: 1 week ago