Question: USE C++ LANGUAGE PLEASE Create two classes (2 .h files, 2 .cpp files, & main.cpp) o Node Should have an int as the data member
USE C++ LANGUAGE PLEASE
Create two classes (2 .h files, 2 .cpp files, & main.cpp)
o Node
Should have an int as the data member
Should maintain a pointer to the next node
Should maintain a pointer to the previous node
o LinkedList
Should manage a set of linked nodes
Should be a DOUBLY LINKED LIST
Ensure that LinkedList has the following functions
o void insert(int thing)
Adds new node that contains the value of thing to the list, but
maintains order. For example, 3 comes before 8.
o void display() const
Displays each node, writing the data to the console (one per line), just
as has been done in class multiple times
Should return "EMPTY if list is empty
Should print "-- DISPLAY " initially (see sample output)
o void displayReverse() const
Same as display(), but shows the nodes in reverse order
Should return EMPTY if list is empty
Should print "DISPLAY REVERSE " initially (see sample output)
o int remove(int thing) const
Deletes any nodes in the list containing same data as thing
o void countNodes(int thing) const
Counts the number of nodes with the same value as thing
o void clear()
Removes (deletes) all nodes in the list
Using the following main() code
int main() {
LinkedList lst;
lst.display();
lst.insert(10);
lst.insert(5);
lst.insert(15);
lst.display();
lst.displayReverse();
lst.insert(10);
cout << "FOUND: " << lst.countNodes(10) << endl;
lst.displayReverse();
lst.remove(15);
lst.remove(17);
lst.insert(3);
lst.display();
lst.clear();
lst.insert(21);
lst.insert(19);
cout << "FOUND: " << lst.countNodes(5) << endl;
lst.displayReverse();
}
Should result in the following output:
--- DISPLAY ---
EMPTY
--- DISPLAY ---
5
10
15
--- DISPLAY REVERSE ---
15
10
5
FOUND: 2
--- DISPLAY REVERSE ---
15
10
10
5
--- DISPLAY ---
3
5
10
10
FOUND: 0
--- DISPLAY REVERSE ---
21
19
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
