Question: File supplied.o contains code that can build, display, and destroy a array of lineked lists . For this lab, you will need to write the

File supplied.o contains code that can build, display, and destroy a array of lineked lists.

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

  • int sum() const

recursively compute and return the sum of the ints contained in the table.

  • int removeTwo()

recursively remove all the 2s from the table

After implementing the two functions, you need to invoke the functions in main.cpp to test. Please label your output so that the result is clear. E.g. sum of all the integers: or After removing all 2:

arr.h

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

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

class table { public: /* These functions are already written */ table(); //supplied ~table(); //supplied void build(); //supplied void display(); //supplied

/* *****************YOUR TURN! ******************************** */ //Write your function prototype here:

private: node ** head; //dynamically allocated array int size; //the array size };

please write require and helper function. As I have to call the function like this ---> object.sum(), object.removeTwo()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!