QuestionQuestion

• Create two classes
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 void remove(int thing)
- Deletes any nodes in the list containing same data as thing
o int countNodes(int thing) const
- Counts the number of nodes with the same value as thing
- Returns the count of nodes found
o void clear()
- Removes (deletes) all nodes in the list

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

#ifndef LINKEDLIST_H
#define LINKEDLIST_H

#include "Node.h"
#include <cstdlib>
#include <iostream>
using namespace std;

template <class T>
class LinkedList {
public:
    LinkedList();
    ~LinkedList();
    void insert(T thing);
    void display() const;
    void displayReverse() const;
    void remove(int thing);
    int countNodes(T thing) const;
    void clear();
private:
    Node<T> * head;
    Node<T> * tail;
};

template <class T>
LinkedList<T>::LinkedList() {
    head = 0;
    tail = 0;
}

template <class T>
LinkedList<T>::~LinkedList() {
    this->clear();
    head = 0;
    tail = 0;
}...

By purchasing this solution you'll be able to access the following files:
Solution.zip.

$30.00
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available C-Family Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats