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:  Double Linked List

Answer: Make a middle node of doubly link list to the top of the list.


August 08, 2009 03:37:53 #2
 f2003062   Member Since: October 2006    Total Comments: 7 

RE: Double Linked List
 
Lets say if the middle node of the doubly linked list is "middle" and the start node is "head".
then the code as follows.

middle->prev->next = middle->next;
middle->next->prev = middle->prev;

// Now make the middle as head.
middle->prev = NULL;
middle->next = head;
head->prev = middle;
head = middle;


     

 

Back To Question