GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

  GeekInterview.com  >  Interview Questions  >  Concepts  >  Data Structures

 Print  |  
Question:  Data Structures Link Conversion

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


November 11, 2008 13:28:42 #1
 rama.sit07   Member Since: November 2008    Total Comments: 1 

RE: Data Structures Link Conversion
 
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
 
    
     

 

Back To Question