create an singly linked lists and reverse the lists by
interchanging the links and not the data?

Answer Posted / bhanu yadav

reverse(node *first) //first address of first node in linked
{ node *x,*temp,*ttemp;
temp=first; //temp at first
ttemp=temp->next; //ttemp next to temp

while(temp->next!=null)
{ x=ttemp->next;
ttemp->next=temp;
temp=ttemp;
ttemp=x;
}
}

Is This Answer Correct ?    3 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Does hashmap sort automatically?

641


Write the algorithm for converting infix expression to postfix expression?

633


Which sorting is best and why?

573


Why do we need arrays if all the operations that are performed on arrays can be performed on arraylist?

512


Write an algorithm to show various operations on ordered list and arrays

598






Explain linear linked implementation of Stack and Queue?

612


What are the main differences between the linked list and linear array?

626


Define linear data structures?

661


Define linked list data structure.

665


Write the steps involved in the insertion and deletion of an element in the stack.

990


Define ancestor and descendant ?

641


What is binary tree in computer science?

567


Give us a program to reverse a linked list.

625


Which sorting does collections sort use?

586


What is faster array or arraylist?

553