Logo

Programming-Idioms

History of Idiom 17 > diff from v22 to v23

Edit summary for version 23 by AllanDeutsch:
[Csharp] Corrected syntax error

Version 22

2016-05-02, 12:12:38

Version 23

2016-05-11, 17:55:53

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
using System.Collections.Generic
Imports
using System.Collections.Generic
Code
class Node<T>
{
 T value;
 List<Node<T>> childNodes
}
Code
class Node<T>
{
 T value;
 List<Node<T>> childNodes;
}
Comments bubble
The Children can be stored in an Array or List, depending on how you want to implement it.
Comments bubble
The Children can be stored in an Array or List, depending on how you want to implement it.