Created
June 11, 2013 16:53
-
-
Save rodrigovilar/5758561 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ArvoreBinaria { | |
public No raiz; | |
public No insere(int chave) { | |
return null; | |
} | |
public int busca(int chave) { | |
return 0; | |
} | |
} | |
class No { | |
public int chave; | |
public No pai; | |
public No direita; | |
public No esquerda; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import static org.junit.Assert.*; | |
import junit.framework.Assert; | |
import org.junit.Test; | |
public class ArvoreBinariaTest { | |
@Test | |
public void cenario1() { | |
ArvoreBinaria arvore = new ArvoreBinaria(); | |
No no5 = arvore.insere(5); | |
No no8 = arvore.insere(8); | |
No no3 = arvore.insere(3); | |
No no2 = arvore.insere(2); | |
No no4 = arvore.insere(4); | |
No no6 = arvore.insere(6); | |
No no7 = arvore.insere(7); | |
No no1 = arvore.insere(1); | |
No no9 = arvore.insere(9); | |
Assert.assertNull(no5.pai); | |
Assert.assertEquals(no5.esquerda, no3); | |
Assert.assertEquals(no3.pai, no5); | |
Assert.assertEquals(no5.direita, no8); | |
Assert.assertEquals(no8.pai, no5); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment