Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct No{
- int numero;
- struct No *esquerda;
- struct No *direita;
- };
- typedef struct No No;
- //Criar Arvore
- void CriarArvore(No **pRaiz)
- {
- *pRaiz = NULL;
- }
- //Contar Nos
- int ContarNos(No *pRaiz){
- if(pRaiz == NULL){
- return 0;
- }
- else{
- return 1 + ContarNos(pRaiz->esquerda) + ContarNos(pRaiz->Direita);
- }
- }
- //Contar Folhas
- int ContarFolhas(No *pRaiz){
- if(pRaiz == NULL){
- return 0;
- }
- if(pRaiz->esquerda == NULL && pRaiz->direita == NULL){
- return 1;
- }
- return contarFolhas(pRaiz->esquerda) + contarFolhas(pRaiz->direita);
- }
- //Altura da Arvore
- int maior(int a,int b){
- if (a > b){
- return a;
- }else{
- return b;
- }
- }//Maior
- int altura(No *pRaiz){
- if((pRaiz == NULL) || (pRaiz->esquerda == NULL && pRaiz->direita == NULL)){
- return 0;
- }else{
- return 1 + maior(altura(pRaiz->esquerda),altura(pRaiz->direita));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement