write a program to Insert in a sorted list
Answers were Sorted based on User's Feedback
node *insert(node *first,int data)
{node *temp,*trav,*cur;
temp->info=data;
temp->next=NULL;
trav=first;
if(data<trav->info)
{temp->next=first;
first=temp;
return first;
}
while(data>trav->info&&trav->next!=NULL)
{cur=trav;
trav=trav->next;
}
if(data>trav->info&&trav->next==NULL)
trav->next=temp;
else
{cur->next=temp;
temp->next=trav;
}
return first;
}
| Is This Answer Correct ? | 10 Yes | 5 No |
Answer / prof.muthu(9962940220)
PLEASE INSERT IN SORTED ORDER....SO,THERE IS NO DIFICULTY OF
RE-ARRANGING THE ELEMENTS...
GOT IT...?
BY THE GREAT PROF.MUTHU
PH:9962940220
| Is This Answer Correct ? | 3 Yes | 5 No |
Answer / kathiresan
node *SLSortWiseInsert(node *START, int data)
{
node *newnode;
if(START == NULL)
{
START = (node *)malloc(sizeof(node));
START->data = data;
START->link = NULL;
return START;
}
else if(data < START->data)
{
newnode = (node *)malloc(sizeof(node));
newnode->data = data;
newnode->link = START;
return newnode;
}
else if((data > START->data) && (START->link == NULL))
{
printf("Inside this condition\n");
newnode = (node *)malloc(sizeof(node));
newnode->data = data;
newnode->link = NULL;
START->link = newnode;
return START;
}
START->link = SLSortWiseInsert(START->link,data);
return START;
}
| Is This Answer Correct ? | 1 Yes | 8 No |
What are segment and offset addresses?
main() { int x=5; clrscr(); for(;x<= 0;x--) { printf("x=%d ", x--); } } a. 5, 3, 1 b. 5, 2, 1, c. 5, 3, 1, -1, 3 d. ā3, -1, 1, 3, 5
Write a program to model an exploding firecracker in the xy plane using a particle system
Is there any difference between the two declarations, 1. int foo(int *arr[]) and 2. int foo(int *arr[2])
write a origram swaoing valu without 3rd variable
How to count a sum, when the numbers are read from stdin and stored into a structure?
1. const char *a; 2. char* const a; 3. char const *a; -Differentiate the above declarations.
main() { int i = 258; int *iPtr = &i; printf("%d %d", *((char*)iPtr), *((char*)iPtr+1) ); }
How to access command-line arguments?
void main() { int const * p=5; printf("%d",++(*p)); }
3 Answers Infosys, Made Easy, State Bank Of India SBI,
programming in c lanugaue programm will errror error with two header file one as stdio.h and other one is conio.h
Which version do you prefer of the following two, 1) printf(ā%sā,str); // or the more curt one 2) printf(str);