can i know the source code for reversing a linked list with
out using a temporary variable?

Answers were Sorted based on User's Feedback



can i know the source code for reversing a linked list with out using a temporary variable? ..

Answer / dinakaran gct

#include<stdio.h>
struct node *head;
void main();
{
//consider head is the first node
reverse(head);
//here print the reversed link list ...thank you;
}
reverse(struct node *cur)
{
if(cur->next==NULL)
reveres(cur->next)
else{temp=head=cur;}
temp->next=cur;
temp=temp->next;
temp->next=NULL;
}

Is This Answer Correct ?    2 Yes 1 No

can i know the source code for reversing a linked list with out using a temporary variable? ..

Answer / vishnu948923

struct node* reverse(struct node* first)
{
struct node* cur, temp;
cur=NULL;
while(first!=NULL)
{
temp=first;
first=first->link;
temp->link=cur;
cur=temp;
}
return cur;
}

Is This Answer Correct ?    5 Yes 5 No

can i know the source code for reversing a linked list with out using a temporary variable? ..

Answer / ruchi

void reverse()
{
nptr p;
int i=0;
p=start;
while(p->next!=NULL)
{
p=p->next;
i=i+1;
}
i++;
while(i)
{
printf("%d\n",p->num);
p=p->prev;
i--;
}
}

Is This Answer Correct ?    1 Yes 1 No

can i know the source code for reversing a linked list with out using a temporary variable? ..

Answer / fazil

void Func( struct Node* List )
{
if( List && List->Next )
{
Func( List->Next );

List->Next->Next = List;
}
}

Is This Answer Correct ?    2 Yes 3 No

can i know the source code for reversing a linked list with out using a temporary variable? ..

Answer / zhangwy

void Func( struct Node* List )
{
if( List && List->Next )
{
Func( List->Next );

List->Next->Next = List;
List->next = NULL ;

}
}

Is This Answer Correct ?    0 Yes 1 No

can i know the source code for reversing a linked list with out using a temporary variable? ..

Answer / abdur rab

struct node* reverse ( struct node* head )
{
struct node* temp;

if ( NULL == head -> next ) temp = head;
else {
temp = reverse ( head -> next );
head -> next -> next = head;
head -> next = NULL;
}
return ( temp );
}

Is This Answer Correct ?    0 Yes 3 No

Post New Answer

More C Interview Questions

dennis ritchie invented C language in AT&T bell laboratory what is the extension of AT&T?

4 Answers  


How arrays can be passed to a user defined function

0 Answers  


If a variable is a pointer to a structure, then which operator is used to access data members of the structure through the pointer variable?

0 Answers  


What is the best way of making my program efficient?

0 Answers  


What is pointers in c?

0 Answers  






What is the difference between specifying a constant variable like with constant keyword and #define it? i.e what is the difference between CONSTANT FLOAT A=1.25 and #define A 1.25

0 Answers  


which type of aspect you want from the student.

0 Answers   IBM, TCS,


implement NAND gate logic in C code without using any bitwise operatior.

4 Answers   Alcatel,


main() { int i=5; printf("%d",++i + i); } output is 10 ------------------------ main() { int i=5; printf("%d",i++ + i); }output is 12 why it is so? give appropiate reason....

2 Answers  


CopyBits(x,p,n,y) copy n LSBs from y to x starting LSB at 'p'th position.

9 Answers   Adobe,


I completed my B.tech (IT). Actually I want to develop virtual object that which will change software technology in the future. To develop virtual object what course I have to take. can I any professor to help me.

0 Answers   Oracle,


What is the sizeof () operator?

0 Answers  


Categories