Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Add in code to complete the Remove method in the following code. Submit a zip of the completed code along with a * . vcxproj

Add in code to complete the Remove method in the following code.
Submit a zip of the completed code along with a *.vcxproj file (if you're using a windows system).
#include
using namespace std;
struct node
{
int data;
struct node* next;
};
class LinkIntList
{
private:
struct node* head;
public:
LinkIntList()
{
head = nullptr;
}
void Add(int x)
{
struct node* newNode = new struct node;
newNode->next = head;
newNode->data = x;
head = newNode;
}
// removes the first node with the value x
// returns true if successful
// returns false if value x isn't found
bool Remove(int x)
{
// Add your code here
}
void PrintAll()
{
struct node* ptr = head;
while (nullptr != ptr)
{
cout << ptr->data <<"";
ptr = ptr->next;
}
cout << endl;
}
};
int main()
{
LinkIntList list;
for (int i=0; i<10; i++)
// populate the list with numbers 0..9
list.Add(i);
list.Remove(10);
list.Remove(9);
list.Remove(7);
list.Remove(0);
list.Remove(4);
list.PrintAll();
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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2019 Wurzburg Germany September 16 20 2019 Proceedings Part 2 Lnai 11907

Authors: Ulf Brefeld ,Elisa Fromont ,Andreas Hotho ,Arno Knobbe ,Marloes Maathuis ,Celine Robardet

1st Edition

3030461467, 978-3030461461

Students also viewed these Databases questions

Question

Write a letter asking them to refund your $1,500 down payment.

Answered: 1 week ago