public void isPalindrome() { // LinkedListNode sec = new LinkedListNode('o'); // LinkedListNode first = new LinkedListNode('t', sec, null); // LinkedListNode third = new LinkedListNode('t', null, sec); // sec.setPrevious(first); LinkedListNode first = new LinkedListNode('t'); LinkedListNode sec = new LinkedListNode('o'); LinkedListNode third = new LinkedListNode('o'); LinkedListNode forth = new LinkedListNode('t'); first.setNext(sec); first.setPrevious(null); sec.setNext(third); sec.setPrevious(first); third.setNext(forth); third.setPrevious(sec); forth.setNext(null); forth.setPrevious(third); Assert.AreEqual(true, palindromeLL.checkPalindrome(first, forth)); }
public void isNotPalindrome() { LinkedListNode first = new LinkedListNode('k'); LinkedListNode sec = new LinkedListNode('h'); LinkedListNode third = new LinkedListNode('o'); LinkedListNode forth = new LinkedListNode('l'); LinkedListNode fifth = new LinkedListNode('o'); LinkedListNode sixth = new LinkedListNode('o'); LinkedListNode seventh = new LinkedListNode('d', null, sixth); first.setNext(sec); first.setPrevious(null); sec.setNext(third); sec.setPrevious(first); third.setNext(forth); third.setPrevious(sec); forth.setNext(fifth); forth.setPrevious(third); fifth.setNext(sixth); fifth.setPrevious(forth); sixth.setNext(seventh); sixth.setPrevious(fifth); seventh.setNext(null); seventh.setPrevious(sixth); Assert.AreEqual(false, palindromeLL.checkPalindrome(first, seventh)); }
public void intersectionShouldReturnNode() { LinkedListNode sec = new LinkedListNode(2); LinkedListNode first = new LinkedListNode(1, sec, null); LinkedListNode third = new LinkedListNode(3, null, null); // sec.setPrevious(first); sec.setNext(third); LinkedListNode forth = new LinkedListNode(4, sec, null); LinkedListNode fifth = new LinkedListNode(5, forth, null); Assert.AreEqual(sec, intersectionLL.isIntersect(first, fifth)); Assert.AreEqual(sec, intersectionLL.isIntersect(first, sec)); Assert.AreEqual(third, intersectionLL.isIntersect(first, third)); Assert.AreEqual(sec, intersectionLL.isIntersect(first, forth)); }
public void intersectionShouldReturnNull() { LinkedListNode sec = new LinkedListNode(2); LinkedListNode first = new LinkedListNode(1, sec, null); LinkedListNode third = new LinkedListNode(3, null, null); sec.setNext(third); LinkedListNode forth = new LinkedListNode(4, null, null); LinkedListNode sixth = new LinkedListNode(6, null, null); forth.setNext(sixth); LinkedListNode fifth = new LinkedListNode(5, forth, null); Assert.AreEqual(null, intersectionLL.isIntersect(first, fifth)); Assert.AreEqual(null, intersectionLL.isIntersect(first, forth)); Assert.AreEqual(null, intersectionLL.isIntersect(first, sixth)); }