writw a program to insert an element in the begning of a
doubly linked list
Answer Posted / mani
#include<stdio.h>
typedef struct node {
int data;
struct node *leftlink;
struct node *rightlink;
}node;
node *start=NULL;
node *tail=NULL;
void add_begin(node *);
main()
{
.......
.......
add_begin(start);
.......
.......
}
void add_begin(node *temp)
{
node *new_node=NULL;
int idata;
printf("enter the data part value: ");
scanf("%d",&idata);
if(start==NULL && tail==NULL )
{
new_node=(node *)malloc(sizeof(node));
new_node->data=idata;
new_node->leftlink=NULL;
new_node->rightlink=NULL;
start=new_node;
tail=new_node;
}
else
{
new_node=(node *)malloc(sizeof(node));
new_node->data=idata;
temp->leftlink=new_node;
new_node->rightlink=temp;
new_node->leftlink=NULL;
start=newnode;
}
}
| Is This Answer Correct ? | 3 Yes | 0 No |
Post New Answer View All Answers
What are linked lists in c?
Explain the advantages of using macro in c language?
Explain what is the difference between a free-standing and a hosted environment?
What are the types of arrays in c?
What is getch() function?
How do c compilers work?
What are pointers? What are different types of pointers?
Where in memory are my variables stored?
What does *p++ do? What does it point to?
Where are c variables stored in memory?
Which node is more powerful and can handle local information processing or graphics processing?
Explain what is the most efficient way to store flag values?
What is string function c?
I need a sort of an approximate strcmp routine?
How can you increase the size of a statically allocated array?