daily pastebin goal
29%
SHARE
TWEET

Segment Tree Visualizer

keverman Apr 2nd, 2018 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. template <class type>
  2. void printTree(type *T, int h)
  3. {
  4.     for(int i = 0; i < h; i++)
  5.     {
  6.         for(int j = 0; j < ((1 << (h - i - 1)) - 1); j++) std::cout << " ";
  7.        
  8.         for(int j = 0; j < ((1 << i) - 1); j++)
  9.         {
  10.             std::cout << T[(1 << i) + j];
  11.             for(int k = 0; k < ((1 << (h - i)) - 1); k++) std::cout << " ";
  12.         }
  13.        
  14.         std::cout << T[(1 << (i + 1)) - 1];
  15.         for(int j = 0; j < ((1 << (h - i - 1)) - 1); j++) std::cout << " ";
  16.        
  17.         std::cout << std::endl;
  18.     }
  19. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top