I am implementing a function which removes duplicates from an unsorted doubly linked list. I removed other functions to keep the code short and more clear. Please assume other functions like InsertFront do work correctly.

I am having trouble attaching the prev pointer from my Node class when I remove a duplicate. I'm not sure if I am attaching the prev pointer correctly. I am currently getting a seg fault. Thank you.

Here is my header file. dlinkedlist.h

```
#ifndef _DLINKEDLIST_H_
#define _DLINKEDLIST_H_

#include <cstdlib>
#include <stdexcept>
#include <string>
#include <iostream> 

using namespace std;

template <class T>
class Node
{
public:
    T data;
    //string data;
    Node<T>* prev;
    Node<T>* next;

    // default constructor
    Node(T value)
    {
        data = value;
        prev = NULL;
        next = NULL;
    }
};

// DLinkedList class definition
template <class T>
class DLinkedList
{
private:
    // DLinkedList private members
    int size; // number of items stored in list
    Node<T>* front; // references to the front
    Node<T>* back;  //  and back of the list

DLinkedList();
DLinkedList(const DLinkedList& ll);
~DLinkedList();

    void RemoveDuplicates();
}

```

Here is my implementation dlinkedlist.cpp

```
#ifdef _DLINKEDLIST_H_

#include <cstdlib>
#include <stdexcept>
#include "dlinkedlist.h"
#include <string>
#include <iostream>
using namespace std;

template <class T>
void DLinkedList<T>::RemoveDuplicates() { 
    Node<T> *current, *runner, *dup;
    current = front;

    cout << "Removing the duplicates..." << endl;

    while (current != NULL && current->next != NULL) {

        runner = current;

        while (runner->next != NULL) {
            if(current->data == runner->next->data) {
                dup = runner->next;
                runner->next = runner->next->next;
                runner->next->prev = runner->next->prev->prev; //trying to connect to previous node. Works without this line.
                delete dup;
            }
            else {
                runner = runner->next;
            }
        }
        current = current->next;
    }

}

```

Here is my test file. test.cpp

```
#include <cstdlib>
#include <iostream>
#include <string>
#include "ccqueue.h"
#include "dlinkedlist.h"
#include "ticket.h"

using namespace std;

void LLTest();

int main()
{
  cout << "\nEntering DLinkedList test function..." << endl;
  LLTest();
  cout << "...DLinkedList test function complete!\n" << endl;
  return 0;
}

void LLTest()
{
  // default constructor, InsertFront, InsertBack, ElementAt
  DLinkedList<int> lla;
  lla.InsertFront(2);
  cout << "-------------------------------------------------\n";
  lla.InsertBack(5);
  lla.InsertBack(10);
  lla.InsertBack(2);
  cout << "-------------------------------------------------\n";
  lla.RemoveDuplicates();
}

```

Thank you for your time.