Logo

Programming-Idioms

History of Idiom 17 > diff from v36 to v37

Edit summary for version 37 by 1.7.4:
New JS implementation by user [1.7.4]

Version 36

2018-08-29, 20:41:05

Version 37

2019-01-23, 17:35:06

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.

Code
class Node {
  constructor (value, children = []) {
    this.value = value
    this.children = children
  }
}