Jump to content

Árvore Binária


SexPistolsPT
 Share

Recommended Posts

estou com um problema na remoção do primeiro elemento de uma árvore binária percorrida de forma infixa.

E em concreto qual é o problema que tens? É na parte de percorrer a árvore? É não saber o que é percorrer de forma infixa? É após encontrar o elemento, não o conseguires remover?

Como é que já tentaste resolver?

Normalmente essa é a forma mais fácil de explicar, uma pessoa indicando onde está errado e como poderás corrigir...

"Give a man a fish and he will eat for a day; Teach a man to fish and he will eat for a lifetime. The moral? READ THE MANUAL !"

Sign on a computer system consultant's desk

Link to comment
Share on other sites

Isso é complicar demasiado.

Penso que basta percorrer a árvore na devida forma e quando não poder percorrer mais (último nodo) então é removê-lo.

Ou estou a ver mal?

"Give a man a fish and he will eat for a day; Teach a man to fish and he will eat for a lifetime. The moral? READ THE MANUAL !"

Sign on a computer system consultant's desk

Link to comment
Share on other sites

Não. Porque se é o primeiro em inorder, significa que é o nó mais à esquerda na árvore e como tal não tem filhos. É só indicar onde está esse nó que passa a estar vazio.

"Give a man a fish and he will eat for a day; Teach a man to fish and he will eat for a lifetime. The moral? READ THE MANUAL !"

Sign on a computer system consultant's desk

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.