function to display a doubly circular list in forward and backward direction
function display ( head ) { if ( head == null ) return ; var temp = head ; document . write ( " " ) ; while ( temp . next != head ) { document . write ( temp . data + " " ) ; temp = temp . next ; } document . write ( temp . data + " " ) ; var last = head . prev ; temp = last ; document . write ( " " ) ; while ( temp . prev != last ) { document . write ( temp . data + " " ) ; temp = temp . prev ; } document . write ( temp . data + " " ) ; }