Advertisement
Guest User

Untitled

a guest
Jun 12th, 2013
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. void getLevelWidth(tree &t, node n, int levelFreqs[], int depth) {
  2.     if (n == NULL)
  3.         return;
  4.    
  5.     levelFreqs[depth]++;
  6.    
  7.    
  8.     while (n != NULL){
  9.         getLevelWidth(t, t.firstChild(n), levelFreqs, depth + 1);
  10.         n = t.nextSibling(n);
  11.         if(n != NULL)
  12.             levelFreqs[depth]++;
  13.     }
  14.    
  15. }
  16.  
  17. int width(tree &t, node n){
  18.     int h = getHeight(t, t.root());
  19.     int* maxLev = new int[h]();
  20.    
  21.     recFindDepths(t, t.root(), maxLev, 0);
  22.    
  23.     return *max_element(maxLev, maxLev + h + 1);
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement