From 7397c5c7b49d6fbab46f40e10236c6b8ed889b31 Mon Sep 17 00:00:00 2001 From: Augusto Date: Wed, 27 Jan 2021 10:20:27 +0000 Subject: [PATCH] Add the subject for the exercise `flat_tree` --- subjects/flat_tree/README.md | 43 ++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 subjects/flat_tree/README.md diff --git a/subjects/flat_tree/README.md b/subjects/flat_tree/README.md new file mode 100644 index 00000000..3ecda4c6 --- /dev/null +++ b/subjects/flat_tree/README.md @@ -0,0 +1,43 @@ +## flat_rust + +### Instructions + +- Define the functions `flatten_tree` that receives a std::collections::BTreeSet and returns a new `Vec` with the elements in the binary tree in order. + +### Expected function + +```rust +pub fn flatten_tree>(tree: &BTreeSet) -> Vec { +} +``` + +### Usage + +Here is a possible test for your function: + +```rust +fn main() { + let mut tree = BTreeSet::new(); + tree.insert(34); + tree.insert(0); + tree.insert(9); + tree.insert(30); + println!("{:?}", flatten_tree(&tree)); + + let mut tree = BTreeSet::new(); + tree.insert("Slow"); + tree.insert("kill"); + tree.insert("will"); + tree.insert("Horses"); + println!("{:?}", flatten_tree(&tree)); +} +``` + +And its output: + +```console +student@ubuntu:~/[[ROOT]]/test$ cargo run +[0, 9, 30, 34] +["Horses", "Slow", "kill", "will"] +student@ubuntu:~/[[ROOT]]/test$ +```