title: How to find middle element of doubly linked list using head and tail?
body: <p>Is there a way possible to find the middle element of a doubly linked list using head and tail. I tried traversing to the next element from the starting node and the previous element from the end node and check if the reference of both is same or not. This works fine if there are odd number of elements in the list. I am not able to find when should I stop in case the number of elements in the list is even.</p>
  
  <pre><code>while(head.next != end.previous) {
      head = head.next;
      end = end.previous;
  }
  </code></pre>