Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Node *deleteNode(int item, Node *head)
- {
- Node *currentNode = head;
- while(currentNode!=NULL){
- if(currentNode->data==item){
- if(currentNode==head){
- head = currentNode->next;
- head->prev=NULL;
- delete(currentNode);
- return head;
- }
- else if(currentNode->next==NULL){
- currentNode->prev->next=NULL;
- delete(currentNode);
- return head;
- }
- currentNode->prev->next = currentNode->next;
- currentNode->next->prev = currentNode->prev;
- delete(currentNode);
- return head;
- }
- currentNode=currentNode->next;
- }
- if(currentNode==NULL)
- cout<<"Data not found in the list\n";
- return head;
- }
Advertisement
Add Comment
Please, Sign In to add comment