Question: The program needs to be in C++, please include the main function and some comment lines for me to understand better. DNode class that can

The program needs to be in C++, please include the main function and some comment lines for me to understand better.

  1. DNode class that can store integer data and the address of next and prev DNode.
  2. Introduce a DLL (Doubly Linked List) class
    1. Introduce a front private data member
    2. Introduce a DLL constructor and destructor
    3. Introduce insertToFront function
    4. Introduce deleteFromFront function
    5. Introduce printAll function
    6. Introduce deleteLast function
    7. Introduce insertToMiddle function
    8. Introduce deleteMiddle function
    9. Introduce deleteLastNode function
    10. InsertInOrder function: insert a new node so the list reads in ascending order from the beginning to the end.
    11. removeOneTargetNode(int target) //remove the first target node found in the list
    12. removeAllTargetNodes(int target)// remove all target node(s) found in the list
    13. isDuplicate //return true if there is any node that are duplicate in the list. For example, 1->2->3->4 is a unique SLL. However, 1->2->3->2->1 is duplicate since 1 repeats two times and 2 repeats two times.
  3. Introduce a CLL (Doubly Linked List) class and all the above functions.

This is the layout I have so far, feel free to use this as a reference or you could use any other methods you may think of:

#include

using namespace std;

class DNode

{

//Public Class Data Members

public:

int data; //Stores item

DNode *next; //Moves to next

DNode *prev; //Moves to previous

}

void print(DNode *head, DNode *tail)

{}

class DLL

{

private:

DNode *front;

DNode *back;

public:

//Constructor

DLL()

{

front = NULL;

}

//Destructor

~DLL()

{

delete front;

delete back;

}

int length()

{}

void insertToFront(int data)

{}

void deleteFromFront()

{}

void printAll()

{}

void deleteLast()

{}

void insertToMiddle(int position, int data)

{}

void deleteMiddle(int position)

{}

void InsertInOrder(DNode *head, DNode *tail, int key)

{}

} ;

int main()

{

DNode *head = NULL;

DNode *tail = NULL;

DNode *node1 = new Node(1);

DNode *node2 = new Node(3);

DNode *node3 = new Node(5);

DNode *node4 = new Node(3);

DNode *node5 = new Node(3);

DNode *node6 = new Node(1);

return 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!