From d2cebe7c1ac2c272b093721a22d989d48ad74d4b Mon Sep 17 00:00:00 2001 From: "Peter J. Keleher" <keleher@cs.umd.edu> Date: Tue, 16 Nov 2021 16:37:29 -0500 Subject: [PATCH] auto --- p5/README.md | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/p5/README.md b/p5/README.md index 732ad15..ec9b031 100644 --- a/p5/README.md +++ b/p5/README.md @@ -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 -"four" -"two" -"three" -"one" +"one": "two", "three" +"two": "four", "" +"three": "", "" +"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 "one": "two", "three" "two": "four", "" "three": "", "" "four": "", "" -> ``` + You will need to define your own implementation for the tree from scratch. Your tree nodes should conform to `TreeNodeInterface`. Operations consist of creating, setting the left -- GitLab