// method to get middle element of LinkedList of generic Type;
public T getMiddle()
{
Node fast = root ;
Node slow = root ;
if (root == null){
System.out.println("List is Empty ");
//Question -----------
//if we have generic method and root is null then we have to return a value
// what should i return here ??
// return slow.data;//
}else{
while(fast.next !=null && fast.next.next != null ){
fast = fast.next.next;
slow = slow.next;
}
return slow.data;
}
}