REVRSE:Bhagalpur Sir
5 posters
Page 1 of 1
REVRSE:Bhagalpur Sir
write a code to reverse a linked list
1)iterative
2)recursive
3)neither iterative nor recursive
1)iterative
2)recursive
3)neither iterative nor recursive
ballu- Posts : 58
Join date : 2009-02-01
Re: REVRSE:Bhagalpur Sir
iska koi solution do yaar mast sa .... (3) wale ka
bhagalpur- Posts : 1
Join date : 2009-02-01
@ bhagalpur sir
Sir aap vo a xor b vaale ki to baat nahi kar rahe.....
During the construction of the linked list instead of the next pointer we can store
prev_pointer (xor) next_pointer
after the construction we will store the first_pointer as the head and last_pointer pointing to the last node...
the code for reversing will be:
temp=first_ponter;
first_pointer=last_pointer;
last_pointer=temp;
During the construction of the linked list instead of the next pointer we can store
prev_pointer (xor) next_pointer
after the construction we will store the first_pointer as the head and last_pointer pointing to the last node...
the code for reversing will be:
temp=first_ponter;
first_pointer=last_pointer;
last_pointer=temp;
shivang- Posts : 42
Join date : 2009-01-30
Age : 35
@ bhagalpur sir
are sir kam se kam 1 baar to traverse karna hi padega reverse karne ke liye. o(1) mein kaise possible hai
mnnit.rahul- Posts : 51
Join date : 2009-02-01
Re: REVRSE:Bhagalpur Sir
I also think of the above solution only.
Traverse the list once in forward direction. Now when u will reach the end, from here start traversing back removing the address of previous node from each node.
Traverse the list once in forward direction. Now when u will reach the end, from here start traversing back removing the address of previous node from each node.
Beagle- Posts : 40
Join date : 2009-01-30
Similar topics
» Constrcutor:Bhagalpur SIr
» Sizeof :bhagalpur Sir
» Design a datastructure - Bhagalpur SIr
» RAND5 to RAND7 : Bhagalpur SIr
» FIBONACCI recursion modified:Bhagalpur Sir
» Sizeof :bhagalpur Sir
» Design a datastructure - Bhagalpur SIr
» RAND5 to RAND7 : Bhagalpur SIr
» FIBONACCI recursion modified:Bhagalpur Sir
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|