public void Add(int data) { DLinkedListNode travel = head; while (travel.next != null) { travel = travel.next; } travel.next = new DLinkedListNode(data); }
public static bool IsPalindrome(DLinkedList li) { DLinkedListNode travel0 = li.head; DLinkedListNode travel1 = li.head; int len = 0; while (travel1.next != null) { travel1 = travel1.next; len++; } len = (len + 1) / 2; for (int i = 0; i < len; i++) { if (travel0.data != travel1.data) { return(false); } travel0 = travel0.next; travel1 = travel1.prev; } return(true); }
public DLinkedListNode(int data) { next = null; prev = null; this.data = data; }