mockers
Would you like to react to this message? Create an account in a few clicks or log in to continue.

REVRSE:Bhagalpur Sir

5 posters

Go down

REVRSE:Bhagalpur Sir Empty REVRSE:Bhagalpur Sir

Post  ballu Sun Feb 01, 2009 10:25 pm

write a code to reverse a linked list
1)iterative
2)recursive
3)neither iterative nor recursive
ballu
ballu

Posts : 58
Join date : 2009-02-01

Back to top Go down

REVRSE:Bhagalpur Sir Empty Re: REVRSE:Bhagalpur Sir

Post  bhagalpur Mon Feb 02, 2009 10:23 am

iska koi solution do yaar mast sa .... (3) wale ka

bhagalpur

Posts : 1
Join date : 2009-02-01

Back to top Go down

REVRSE:Bhagalpur Sir Empty @ bhagalpur sir

Post  shivang Mon Feb 02, 2009 3:08 pm

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;

cheers
shivang
shivang

Posts : 42
Join date : 2009-01-30
Age : 35

Back to top Go down

REVRSE:Bhagalpur Sir Empty @ bhagalpur sir

Post  mnnit.rahul Mon Feb 02, 2009 3:22 pm

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

Back to top Go down

REVRSE:Bhagalpur Sir Empty Re: REVRSE:Bhagalpur Sir

Post  Beagle Mon Feb 02, 2009 3:24 pm

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.

Beagle

Posts : 40
Join date : 2009-01-30

Back to top Go down

REVRSE:Bhagalpur Sir Empty Re: REVRSE:Bhagalpur Sir

Post  Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum