Advertisement
aleix616

Nombre d'aparicions d'un valor en un arbre general

Jun 5th, 2015
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.42 KB | None | 0 0
  1. static int i_freq(node_arbreGen* n, const T& x){
  2.     if (n != NULL){
  3.         int freq = 0;
  4.         if (n->info == x) freq++;
  5.         for (int i = 0; i < n->seg.size(); i++)
  6.             freq += i_freq(n->seg[i],x);
  7.         return freq;
  8.     } else return 0;
  9. }
  10.  
  11. int freq(const T& x) const
  12. /* Pre: cert */
  13. /* Post: el resultat indica el nombre d'aparicions de x en el p.i. */
  14. {
  15.     return i_freq(primer_node, x);
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement