Question: Consider the Node structure as following / * Node of a doubly linked list * / struct Node { int data; Node * next; /

Consider the Node structure as following
/* Node of a doubly linked list */
struct Node {
int data;
Node *next; // Pointer to next node in DLL
Node *prev; // Pointer to previous node in DLL
};
What will be the code for missing step in C++?// may need two lines of code
/* Given a reference (pointer to pointer) to the head of a list and an int, inserts a new node on the front of the list. */
void push(Node** head_ref, int new_data){
/*1. allocate new node */
/*2. put in the data into new node */
/*3. Make next of new node as head and previous as NULL */
/*4. change prev of head node to new node */
/*5.______________________*/
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!