Question: C++ Assignment, please help For this assignment, you must (partially) reimplement the std::list class. You will find it useful to implement a class called ListNode,

C++ Assignment, please help For this assignment, you must (partially) reimplement the std::list class.

You will find it useful to implement a class called ListNode, which contains two elements: a data field of type T, and a pointer to the next ListNode in the list

Your version, called MyList, must have the following functions:

  • void insert(T item)
  • void delete(T item)
  • T* search(T item)
  • MyList merge(MyVector vec)
  • T min()
  • T max()

insert should insert the item at theendof the MyList

search should return a pointer to thefirst occurrence of theitem, or nullptr if the item isn't in the list.

searchByIndex should return the index of the first occurrence of the item. If not found, return -1

max and min should return the maximum or minimum value stored in the list.

delete should search for the parameter in the MyList, and remove it if found. I recommend writing pseudocode for handling re-wiring the linked list after a delete before implementing the actual code. I also recommend thinking hard about edge cases -- for example, how does it work when the list is empty? when the list has only one element? when the list has two or more elements?THIS IS PROBABLY THE HARDEST FUNCTION TO IMPLEMENT

merge should return a MyList containing all the elements of both this list and the parameter list.

MyList should use a dynamically allocated linked list to store data. T can be any type that can be compared using the

Your implementationmust notleak memory.

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 Programming Questions!