alonso284

Node.hpp

Feb 10th, 2024
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.34 KB | None | 0 0
  1. #pragma once
  2. #include <iostream>
  3.  
  4. template<class T>
  5. class Node{
  6. public:
  7.     Node<T> *left;
  8.     Node<T> *right;
  9.     T data;
  10.     unsigned int height;
  11.     Node(const T &data, Node<T> *left = nullptr, Node<T> *right = nullptr): data(data), left(left), right(right),
  12.     height(1 + std::max((left? left -> height:0), (right? right -> height:0)))
  13.     {};
  14. };
Advertisement
Add Comment
Please, Sign In to add comment