Last active
August 29, 2015 14:07
-
-
Save luis-l/fdfb455f89f07f31464a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void remove(int x) | |
{ | |
node *p=top; | |
node *q=NULL; | |
while(p!=NULL) | |
{ | |
if(p->data==x) | |
q=p; | |
p=p->next; | |
} | |
removeNode(q); | |
} | |
void removeNode(node* target){ | |
if(target==top) | |
removeFront(); | |
else if(target==bottom) | |
removeBack(); | |
//some node in between | |
else | |
{ | |
target->prev->next=target->next; | |
target->next->prev=target->prev; | |
delete target; | |
} | |
} | |
void tricmate() | |
{ | |
int counter = 1; | |
node* current = top; | |
node* next; | |
while(current != NULL){ | |
next = current->next; //save next node | |
//third element found | |
if(counter == 3){ | |
counter = 0; //reset counter | |
removeNode(current); | |
} | |
current = next; | |
counter++; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment