Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Created New Exercise: Retree #1424

Merged
merged 11 commits into from
Jan 8, 2019
120 changes: 60 additions & 60 deletions exercises/retree/canonical-data.json
Original file line number Diff line number Diff line change
@@ -1,66 +1,66 @@
{
"exercise": "retree",
"version": "1.0.0",
"cases": [
{
"description": "Empty tree",
"property": "treeFromTraversals",
"input": {
"preorder": [],
"inorder": []
},
"expected": {}
"exercise": "retree",
"version": "1.0.0",
"cases": [
{
"description": "Empty tree",
"property": "treeFromTraversals",
"input": {
"preorder": [],
"inorder": []
},
{
"description": "Tree with one item",
"property": "treeFromTraversals",
"input": {
"preorder": ["a"],
"inorder": ["a"]
},
"expected": {"v":"a", "l": {}, "r": {}}
"expected": {}
},
{
"description": "Tree with one item",
"property": "treeFromTraversals",
"input": {
"preorder": ["a"],
"inorder": ["a"]
},
{
"description": "Tree with many items",
"property": "treeFromTraversals",
"input": {
"preorder": ["a", "i", "x", "f", "r"],
"inorder": ["i", "a", "f", "x", "r"]
},
"expected": {"v": "a",
"l": {"v": "i", "l": {}, "r": {}},
"r": {"v": "x",
"l": {"v": "f", "l": {}, "r": {}},
"r": {"v": "r", "l": {}, "r": {}}
}
}
"expected": {"v":"a", "l": {}, "r": {}}
This conversation was marked as resolved.
Show resolved Hide resolved
},
{
"description": "Tree with many items",
"property": "treeFromTraversals",
"input": {
"preorder": ["a", "i", "x", "f", "r"],
"inorder": ["i", "a", "f", "x", "r"]
},
{
"description": "Reject traversals of different length",
"property": "treeFromTraversals",
"input": {
"preorder": ["a", "b"],
"inorder": ["b", "a", "r"]
},
"expected": {"error": "traversals must have the same length"}
"expected": {"v": "a",
"l": {"v": "i", "l": {}, "r": {}},
"r": {"v": "x",
"l": {"v": "f", "l": {}, "r": {}},
"r": {"v": "r", "l": {}, "r": {}}
}
}
},
{
"description": "Reject traversals of different length",
"property": "treeFromTraversals",
"input": {
"preorder": ["a", "b"],
"inorder": ["b", "a", "r"]
},
{
"description": "Reject inconsistent traversals of same length",
"property": "treeFromTraversals",
"input": {
"preorder": ["x", "y", "z"],
"inorder": ["a", "b", "c"]
},
"expected": {"error": "traversals must have the same elements"}
"expected": {"error": "traversals must have the same length"}
},
{
"description": "Reject inconsistent traversals of same length",
"property": "treeFromTraversals",
"input": {
"preorder": ["x", "y", "z"],
"inorder": ["a", "b", "c"]
},
{
"description": "Reject traversals with repeated items",
"property": "treeFromTraversals",
"input": {
"preorder": ["a", "b", "a"],
"inorder": ["b", "a", "a"]
},
"expected": {"error": "traversals must contain unique items"}
}
]
}
"expected": {"error": "traversals must have the same elements"}
},
{
"description": "Reject traversals with repeated items",
"property": "treeFromTraversals",
"input": {
"preorder": ["a", "b", "a"],
"inorder": ["b", "a", "a"]
},
"expected": {"error": "traversals must contain unique items"}
}
]
}