Skip to content
Snippets Groups Projects
Commit d2cebe7c authored by Peter J. Keleher's avatar Peter J. Keleher
Browse files

auto

parent 104a2773
No related branches found
No related tags found
No related merge requests found
...@@ -134,21 +134,37 @@ read strings: [one two three] ...@@ -134,21 +134,37 @@ read strings: [one two three]
> >
``` ```
You tree should make calls that roughly mirror:
```
one := createTreeNode(uint64(rand.Intn(1000)), "one")
two := createTreeNode(uint64(rand.Intn(1000)), "two")
three := createTreeNode(uint64(rand.Intn(1000)), "three")
four := createTreeNode(uint64(rand.Intn(1000)), "four")
SetLeft(one.oid, two.oid)
SetRight(one.oid, three.oid)
SetLeft(two.oid, four.oid)
```
and then print out, for each node, the label, and the labels of the left and right children:
``` ```
> go run tree.go > go run tree.go
"four" "one": "two", "three"
"two" "two": "four", ""
"three" "three": "", ""
"one" "four": "", ""
> >
```
Likewise, another *reader* process running at the same time should see the same tree-node creation and mutation events, construct an exact copy of the tree, and print out the same representation:
```
> go run tree.go -r > go run tree.go -r
"one": "two", "three" "one": "two", "three"
"two": "four", "" "two": "four", ""
"three": "", "" "three": "", ""
"four": "", "" "four": "", ""
>
``` ```
You will need to define your own implementation for You will need to define your own implementation for
the tree from scratch. Your tree nodes should conform to the tree from scratch. Your tree nodes should conform to
`TreeNodeInterface`. Operations consist of creating, setting the left `TreeNodeInterface`. Operations consist of creating, setting the left
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment