Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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

How to print India by nested loop? I IN IND INDI INDIA

4 Answers   NIIT, Wipro,


Explain logical errors? Compare with syntax errors.

0 Answers  


Explain what does it mean when a pointer is used in an if statement?

0 Answers  


What are linker error?

0 Answers  


What is function in c with example?

0 Answers  


Why is C called a middle-level language?

1 Answers  


Can we access RAM? How? Whats the range of access? Similarly What are other hardware we can access?

1 Answers  


What is the data segment that is followed by c?

0 Answers  


What are the different types of pointers used in c language?

0 Answers  


main() { int a = 65; printf(“%d %o %x”,a,a,a); } Output 65 101 41 Please explain me.How it is coming like that?

3 Answers   Excel,


my project name is adulteration of chille powder.how can i explain it to the hr when he asks me about the project?

0 Answers  


what is the similarities between. system call and library function?

1 Answers   Wipro,


Categories