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
How many loops are there in c?
What is %d called in c?
How do I copy files?
find out largest elemant of diagonalmatrix
Explain what are linked list?
how to solve "unable to open stdio.h and conio.h header files in windows 7 by using Dos-box software
How pointer is different from array?
Is there any algorithm to search a string in link list in the minimum time?(please do not suggest the usual method of traversing the link list)
What is spaghetti programming?
Which is the memory area not included in C program? give the reason
in any language the sound structure of that language depends on its a) character set, input/output function, its control structures b) character set, library functions, input/output functions its control structures c) character set, library functions, control sturctures d) character set, operators, its control structures
What are shell structures used for?
What is the difference between union and structure in c?
Why are all header files not declared in every c program?
When is the “void” keyword used in a function?