Data Structures Link Conversion

How do you convert doubly linked list to single without using structures?

Questions by phaniraj baggolli   answers by phaniraj baggolli

Showing Answers 1 - 4 of 4 Answers

rama.sit07

  • Nov 1st, 2008
 

Suppose you are given doubly linked list with starting adress as p, then program for converting doubly linked list into singly list is (this is not a program just an algorithm)
 node structure is defined as
   class node
   {
       int info;
       node lptr,rptr;
    }
  main()
{
    node p,q,r;
    q=r=p;
    while(p!=null)
    {
          q=q.rptr;
          q.lptr=null;
     }
 }
now p points to  the first node and behaves like a singly linked list
 
    

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions