I need to implement a binary search tree, but I don’t understand what to write to the key (key) date is the entered data (for example, numbers or Chara elements) Something like id, but I don’t understand how to further implement it all) help here is a piece of code

template<typename T, typename K> class Tree { class Node { public: Node() :data_(0), key(0), left(nullptr), right(nullptr) {}; //не факт что я здесь все верно написал Node(T d, K k) :data_(d), key(k), left(nullptr), right(nullptr) {}; //и здесь friend Tree; //Node(T); ~Node(); private: T data_; K key; Tree *left; Tree *right; }; Tree() :root(nullptr) {}; Tree *root; }; 

    1 answer 1

    The key contains the values ​​for which the search will be performed, and the data itself - the data itself. For example, you may have a structure that contains information about students, and you want to organize a search by last name. Then the key will be the last name, which may be stored as an object of a character array or the standard class std :: string, and the entire structure describing the student, in which, in addition to the last name, there may be such information as birth date, academic performance, group number, etc.