Advertisement
Guest User

PrintTree

a guest
Apr 23rd, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.58 KB | None | 0 0
  1. //i parametri da passare sono l'albero e due numeri(io ci metto 10 e 10 di solito servono per la visualizzazione)
  2. void print2DUtil(tree root, int space, int COUNT)
  3. {
  4.     // Base case
  5.     if (root == NULL)
  6.         return;
  7.  
  8.     // Increase distance between levels
  9.     space = space + COUNT;
  10.  
  11.     // Process right child first
  12.     print2DUtil(root->right, space, COUNT);
  13.  
  14.     // Print current node after space
  15.     // count
  16.     printf("\n");
  17.     for (int i = COUNT; i < space; i++)
  18.         printf("  ");
  19.    
  20.     printf("%s\n", root->value.cognome);
  21.    
  22.  
  23.  
  24.     // Process left child
  25.     print2DUtil(root->left, space, COUNT);
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement