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 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

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

Students also viewed these Databases questions

Question

Which of the following is not a concern about IoT?

Answered: 1 week ago

Question

Explain how to build high-performance service delivery teams.

Answered: 1 week ago