Advertisement
aleix616

Màxim d'un arbre n-ari

Jun 5th, 2015
366
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.46 KB | None | 0 0
  1. static void i_maxim(node_arbreNari* n, T &max){
  2.     max = n->info;
  3.         for (int i = 0; i < n->seg.size(); i++){
  4.             if (n->seg[i] != NULL){
  5.             T aux;
  6.             i_maxim(n->seg[i],aux);
  7.             if (max < aux) max = aux;
  8.             }
  9.         }
  10.     }
  11.  
  12. T maxim() const
  13. /* Pre: el p.i. no és buit */
  14. /* Post: el resultat indica el valor més gran que conté el p.i. */
  15. {
  16.     T max;
  17.     i_maxim(primer_node,max);
  18.     return max;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement