Calcolare l’altezza di un albero

int altezza(nodo *x){
 if(!x) return -1;  //se l'albero è vuoto ritorno -1
 else{
   int a=altezza(x->left);  //vado a sinistra
   int b=altezza(x->right);  //vado a destra
   if(a>b) return a+1;  //sommo 1 ad a
     return b+1;  //sommo 1 ad b
 }
}
Tothebit

About Tothebit

How to whitelist website on AdBlocker?

How to whitelist website on AdBlocker?

  1. 1 Click on the AdBlock Plus icon on the top right corner of your browser
  2. 2 Click on "Enabled on this site" from the AdBlock Plus option
  3. 3 Refresh the page and start browsing the site