Advertisement
JosepRivaille

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

Jan 10th, 2016
401
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 freq_immersive(node_arbreGen *n, const T &x)
  2. {
  3.     int count = 0;
  4.     if (n != NULL) {
  5.         if (n->info == x) ++count;
  6.         for (int i = 0; i < n->seg.size(); ++i) {
  7.             count += freq_immersive(n->seg[i], x);
  8.         }
  9.     }
  10.     return count;
  11. }
  12.  
  13. int freq(const T& x) const
  14. /* Pre: cert */
  15. /* Post: el resultat indica el nombre d'aparicions de x en el p.i. */
  16. {
  17.     return freq_immersive(this->primer_node, x);
  18. }
  19.  
  20. //JosepRivaille
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement