From 024bcf2d40a8075c3e9a214c53c65e50bdeb4a45 Mon Sep 17 00:00:00 2001 From: Glenn Jackman Date: Tue, 10 Sep 2024 12:25:58 -0400 Subject: [PATCH] Clarifications for binary-search-tree exercise --- .../binary-search-tree/.docs/instructions.append.md | 12 ++++++++++++ .../binary-search-tree/binary-search-tree.coffee | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 exercises/practice/binary-search-tree/.docs/instructions.append.md diff --git a/exercises/practice/binary-search-tree/.docs/instructions.append.md b/exercises/practice/binary-search-tree/.docs/instructions.append.md new file mode 100644 index 00000000..b0b3f238 --- /dev/null +++ b/exercises/practice/binary-search-tree/.docs/instructions.append.md @@ -0,0 +1,12 @@ +# ignore + +## CoffeeScript specific instructions + +A BinarySearchTree instance must have 3 properties: `data`, `left` and `right`. + +An instance must have these methods: + +* `insert` which adds a new piece of data to the tree. This will add a new "leaf" node somewhere in the tree. +* `each` that takes a "callback" argument. That is a function that will be called on _each piece of data_ in the tree **in order**. + +This exercise is a great place to practice **recursion**. diff --git a/exercises/practice/binary-search-tree/binary-search-tree.coffee b/exercises/practice/binary-search-tree/binary-search-tree.coffee index e843b0e9..eab0b9b7 100644 --- a/exercises/practice/binary-search-tree/binary-search-tree.coffee +++ b/exercises/practice/binary-search-tree/binary-search-tree.coffee @@ -4,6 +4,6 @@ class BinarySearchTree insert: (args) -> - data: -> + each: (callback) -> module.exports = BinarySearchTree