Question: 2. Assignment Implement a class that represents a linked list of integers. The class should have the following methods: - void insert(int value): Inserts a

 2. Assignment Implement a class that represents a linked list of
integers. The class should have the following methods: - void insert(int value):
Inserts a new node with the given at the end of the

2. Assignment Implement a class that represents a linked list of integers. The class should have the following methods: - void insert(int value): Inserts a new node with the given at the end of the list. - bool contains(int value): Returns if the list contains a node with the given value, and otherwise. - int size(): Returns the in the list. For example, the following code should be valid: \#inctude using namespace std; struct Node \{ int data; Node* next; Node(int value) \{ this data = value; this next = NULL; \} class UnorderedList \{ public: Node head; 1/ Constructor UnorderedList () \{ head = NULL; \} 1I Function to insert a node at the end of the linked list. void insert(int value) \{ lladd code below this line lladd code above this line \} 1/ Function to calcluate the size of linked list. int size( ) \{ l/add code below this line 1/ Function to calcluate the size of linked list. int size () \{ I/add code below this line lladd code above this line J I/ Function to check if the list contains a node with the given value or not bool contains (int value) \{ lladd code below this line lladd code above this line \} f 1I Function to print the values of linked list. void printlist(Node* head) \{ Node p= head; while (p I= nuZlptr) \{ std: : cout p> data std: : endl; p=p> next; \} \} int main(int argc, char* argv[]){ int size = stoi (argv[1]); int element 1=stoi(argv[2]); int element 2=stoi(argv[3]); int element3 = stoi (argv[4]); Unorderedlist list; (2:1)

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!