@Test public void p10() { n0.left = n1; n1.left = n2; n1.right = n3; n0.right = n4; Assert.assertEquals(new Integer(2), Ch9.p10(n0).data.data); Assert.assertEquals(new Integer(3), Ch9.p10(n0).next.data.data); Assert.assertEquals(new Integer(4), Ch9.p10(n0).next.next.data.data); Assert.assertEquals(null, Ch9.p10(n0).next.next.next); Assert.assertEquals(null, Ch9.p10(null)); }
@Test public void p5() { n0.left = n1; n1.left = n2; n2.right = n3; n0.right = n4; n3.left = n5; n1.parent = n0; n2.parent = n1; n3.parent = n2; n4.parent = n0; n5.parent = n3; Assert.assertEquals("253104", Ch9.p5(n0)); }
@Test public void p13and14() { n1.left = n2; n2.left = n4; n4.left = n6; n2.right = n3; n1.right = n5; n5.parent = n1; n2.parent = n1; n3.parent = n2; n4.parent = n2; n6.parent = n4; Assert.assertEquals(new Integer(2), Ch9.p13(n3, n6).data); Assert.assertEquals(new Integer(2), Ch9.p14(n3, n6).data); }
@Test public void p1() { n0.left = n1; n0.right = n2; n2.right = n3; Assert.assertTrue(Ch9.p1(n0)); n3.right = n4; Assert.assertFalse(Ch9.p1(n0)); }