Answer to Question #255775 in C for Lucifer

Question #255775
1. void deleteNodeFromStart(struct node_d ** head) 2. void insertNodeAtStart(struct node_d ** head) complete these functions for circular doubly linked list
1
Expert's answer
2021-10-24T11:51:24-0400
#include<iostream>
using namespace std;
struct Node{
	int data;
	struct Node * next;
	struct Node * prev;
};


void insertNodeAtStart(struct Node** head, int value)
{
    
    struct Node *last = (*head)->prev;
 
    struct Node* new_node = new Node;
    new_node->data = value;   
 
    
    new_node->next = *head;
    new_node->prev = last;
 
    
    last->next = (*head)->prev = new_node;
 
   
    *head = new_node;
}


void deleteNodeFromStart(struct Node** head){
   struct Node *Ptr = (*head);
   struct Node *first =(*head);
    if (head == NULL) return;
    first = first->next;
    first->prev = NULL;
    free(Ptr);
    head = &first;
}
int main(){
	
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS