Logo

Programming-Idioms

History of Idiom 17 > diff from v25 to v26

Edit summary for version 26 by AllanDeutsch:
New Cpp implementation by user [AllanDeutsch]

Version 25

2016-05-16, 21:59:39

Version 26

2016-05-16, 22:00:45

Idiom #17 Create a Tree data structure

The structure must be recursive. A node may have zero or more children. A node has access to children nodes, but not to its parent.

Idiom #17 Create a Tree data structure

The structure must be recursive. A node may have zero or more children. A node has access to children nodes, but not to its parent.

Imports
#include <memory>
Code
template<typename T>
struct Node{
  T value;
  std::unique_ptr<Node<T>> left;
  std::unique_ptr<Node<T>> right;
};