#include <iostream>
using namespace std;
struct Node{
int data;
struct Node* prev;
struct Node* next;
};
struct Node* insert(struct Node* head, int data);
struct Node* insertAtBeg(struct Node* head, int data);
struct Node* insertAtPos(struct Node* head, int pos, int data);
int main() {
struct Node* head;
head = NULL;
// Why sending head
// What does head contains
// does head contains NULL or what
//yes head contains NULL which means its not pointing to anything
//in the first insert it just passed as value
head = insert(head,10);
head = insertAtBeg(head,1);
head = insertAtPos(head,2,13);
// head = insert(head,1);
// head = insertAtBeg(head,10);
// head = insertAtPos(head,25,2);
// head = insert(head,56);
return 0;
}
struct Node* insert(struct Node* head, int data){
struct Node* temp = new Node();
temp->prev = NULL;
temp->next = NULL;
temp->data = data;
if(head == NULL){
head = temp;
return head;
}
Node* temp1 = head;
while(temp1->next != NULL){
temp1 = temp1.next;
}
temp->prev = temp1;
temp1->next = temp;
return head;
}
struct Node* insertAtBeg(struct Node* head, int data){
struct Node* temp = new Node();
temp->prev = NULL;
temp->next = NULL;
temp->data = data;
if(head == NULL){
head = temp;
return head;
}
temp->next = head;
head->prev = temp;
head = temp;
return head;
}
struct Node* insertAtPos(struct Node* head, int pos, int data){
struct Node* temp = new Node();
temp->prev = NULL;
temp->next = NULL
temp->data = data;
if(head == NULL){
head = temp;
return head;
}
Node* temp1;
temp1 = head;
for(int i =1; i<pos-1; ++i){
temp1 = temp1->next;
}
struct Node* temp2;
temp2 = temp1->next;
temp->prev =
}