private void PercorrerInfixado(Noh no)
 {
     if (no != null)
     {
         PercorrerInfixado(no.Esquerda);
         Console.Write($"{no.Valor}   ");
         PercorrerInfixado(no.Direita);
     }
 }
 static int RetornarQuantidadeNosEmArvore(Noh no)
 {
     if (no == null)
     {
         return(0);
     }
     else
     {
         return(1 + RetornarQuantidadeNosEmArvore(no.Direita) +
                RetornarQuantidadeNosEmArvore(no.Esquerda));
     }
 }
        static Arvore CriarArvoreBinariaPorLista(int[] numeros)
        {
            Arvore arvoreBinaria = new Arvore();

            foreach (var item in numeros)
            {
                Noh novoNoh = new Noh(item);
                arvoreBinaria.InserirNoBin(novoNoh);
            }
            Console.WriteLine("Árvore criada!");
            return(arvoreBinaria);
        }
 static int RetornarSomaElementosEmArvore(Noh no)
 {
     if (no == null)
     {
         return(0);
     }
     else
     {
         int soma = 0;
         soma += RetornarSomaElementosEmArvore(no.Esquerda);
         soma += RetornarSomaElementosEmArvore(no.Direita);
         soma += no.Valor;
         return(soma);
     }
 }
 private Noh Inserir(Noh atual, Noh novoNo)
 {
     if (atual == null)
     {
         return(novoNo);
     }
     else if (novoNo.Valor < atual.Valor)
     {
         atual.Esquerda = Inserir(atual.Esquerda, novoNo);
     }
     else
     {
         atual.Direita = Inserir(atual.Direita, novoNo);
     }
     return(atual);
 }
        static int RetornarMaiorValorEmArvore(Noh no)
        {
            int maiorAtual = no.Valor;
            int maiorValor = maiorAtual;

            if (no.Esquerda != null)
            {
                int maiorEsquerda = RetornarMaiorValorEmArvore(no.Esquerda);
                if (maiorEsquerda > maiorValor)
                {
                    maiorValor = maiorEsquerda;
                }
            }
            if (no.Direita != null)
            {
                int maiorDireita = RetornarMaiorValorEmArvore(no.Direita);
                if (maiorDireita > maiorValor)
                {
                    maiorValor = maiorDireita;
                }
            }
            return(maiorValor);
        }
 public void InserirNoBin(Noh novoNo)
 {
     Raiz = Inserir(Raiz, novoNo);
 }