Question: Doubly Linked List. Class should be called DoublyLinkedList. The Node structure , with fields prev, item, and next. You will want to add a pointer

Doubly Linked List. Class should be called DoublyLinkedList. The Node structure , with fields prev, item, and next. You will want to add a pointer to the last node in the list as discussed in class. All existing methods must be suitably modified. Copy Constructor Add a new method void reverse() which reverses the list. it must reverse the list simply by modifying pointers. Add a new method called vector toVector(bool reverse) that returns a vector (the vector class is in the C++ standard library!) populated with the items in the list, in forward order, unless reverse is true, in which case the vector should be populated with the list items in reverse order (the list itself does not change). Remember you can easily go through a doubly linked list in either order, and you have a tail pointer so you now where the last node The Main Program First Create a sub-routine void print(const char* msg, const vector& vec) that will print the msg passed, followed by the contents of the vector. For example, if the msg is Hello, and vector contains XX, YY, ZZ, the print function would print: Hello [ XX YY ZZ ] . Create a DoublyLinkedList of strings (typedef string E), using the add method, that contains this data: AA, BB, CC, DD, EE 2. Call toVector(false) and print the resulting vector by calling the print method with msg S2. The items should print in forward order .Call toVector(true) and print the resulting vector by calling the print method with msg S3. The items should print in reverse order . Call add(0, XX); add(3, YY); add(7, ZZ) . Call toVector(false) and print the resulting vector by calling the print method with msg S5. The items should print in forward order 6. Call toVector(true) and print the resulting vector by calling the print method with msg S6. The items should print in reverse order . Create a new list as a copy of the existing list using the copy constructor: DoublyLinkedList list2(list1) or DoubleLinkedList list2 = list1; Using this new list (list2): . Call toVector(false) and print the resulting vector by calling the print method with msg S8. The items should print in forward order . Call remove(0); remove(2); remove(5); . Call toVector(false) and print the resulting vector by calling the print method with msg S10. The items should print in forward order . Call reverse();Call toVector(false) and print the resulting vector by calling the print method with msg . The items should print in the new forward order . Call toVector(true) and print the resulting vector by calling the print method with msg . The items should print in the new reverse order

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!