Skip to content

Instantly share code, notes, and snippets.

@rodrigovilar
Forked from anonymous/ArvoreBinaria.java
Created June 11, 2013 16:51
Show Gist options
  • Save rodrigovilar/5758537 to your computer and use it in GitHub Desktop.
Save rodrigovilar/5758537 to your computer and use it in GitHub Desktop.
public class ArvoreBinaria {
public No raiz;
public No insere(int chave) {
return null;
}
public int busca(int chave) {
return 0;
}
}
class No {
public No pai;
public No direita;
public No esquerda;
}
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