Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void remover(int x, int q, Arquivo a) {
- this.raiz = remover_rec(x, q, this.raiz, a);
- this.altura = 0;
- }
- No remover_rec(int x, int q, No raiz, Arquivo a) {
- if (raiz.n == x) {
- if (raiz.q > q) {
- raiz.q -= q;
- a.print(altura + " " + raiz.q);
- } else if (q >= raiz.q) {
- if ((raiz.d == null) && (raiz.e == null)) { // É UMA FOLHA
- raiz = null;
- a.print(this.altura + " 0");
- } else if((raiz.d == null) && (raiz.e != null)) {
- raiz = raiz.e;
- a.print(this.altura + " 0");
- } else if((raiz.d != null)) {
- No aux = raiz.d;
- while(aux.e != null) {
- aux = aux.e;
- }
- // raiz = // terminar
- }
- }
- } else if (x > raiz.n) {
- if (raiz.d != null) {
- altura++;
- raiz.d = remover_rec(x, q, raiz.d, a);
- } else {
- a.print("-1 0");
- }
- } else if (x < raiz.n) {
- if (raiz.e != null) {
- altura++;
- raiz.e = remover_rec(x, q, raiz.e, a);
- } else {
- a.print("-1 0");
- }
- }
- return raiz;
- }
Add Comment
Please, Sign In to add comment