// DeleteAlternateNodesInDoubleList.cpp : Defines the entry point for the console application.
#include "stdafx.h"

struct Node {
   
int Value;
    Node* Next;
   
Node* Previous;
};

Node *Head, *Tail;

void Delete(Node *node) {
   
if (node->Previous == NULL)
        Head = node->Next;
   
else
        node->Previous->Next = node->Next;

   
if (node->Next == NULL)
        Tail = node->Previous;
   
else
        node->Next->Previous = node->Previous;
}

void Append(Node *node){
   
if (Head == NULL) {
        Head = node;
        node->Previous = NULL;
    }
   
else {
        Tail->Next = node;
        node->Previous = Tail;
   
}

    Tail = node;
    node->Next = NULL;
}

int _tmain(int argc, _TCHAR* argv[]) {
    Node *node;
   
   
// Add items to linked list
    for (int i = 0; i < 10; i++) {
        node =
new Node;
        node->Value = i;
        Append(node);
   
}

    //delete alternate
    int flag = 0;
    Node* current = Head;
   
while(current) {
       
if(flag) {
            Delete(current);
        }
        flag = !flag;
        current = current->Next;
    }
   
return 0;
}