Skip to content

Commit 0f9c86b

Browse files
committed
Add error as a potential return value for DFS RI Binary
To be able to return an error and to apply suggestion by thbwd (https://github.com/algorithm-archivists/algorithm-archive/pull/ 471#discussion_r223597592) the following changes were made: - Declare an enum to hold the error value. - Rewrite the Depth-First Search Recursive Inorder Binary method to return an optional holding the enum and adjust the returns according to that. - Call the rewritten method and check, if the returned optional holds error. If it does: Print out the error message defined in the enum. Signed-off-by: Julian Schacher <jspp@posteo.net>
1 parent f5028a6 commit 0f9c86b

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

contents/tree_traversal/code/emojicode/tree_traversal.emojic

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
🦃 ⏹ 🍇
2+
🔘 ⏫
3+
4+
❗️ 🔡 ➡️ 🔡 🍇
5+
↪️ 🐕 🙌 🆕⏹⏫❗️ 🍇
6+
↩️ 🔤The given tree is not binary!🔤
7+
🍉
8+
↩️ 🔤🔤
9+
🍉
10+
🍉
11+
112
🐇 🌲 🍇
213
🖍🆕 id 🔢
314
🖍🆕 children 🍨🐚🌲🍆
@@ -46,9 +57,9 @@
4657
Depth-First Search Recursive Inorder Binary
4758
This assumes only 2 children.
4859
📗
49-
❗️ 🍭 🍇
60+
❗️ 🍭 ➡️ 🍬⏹ 🍇
5061
↪️ 🐔 children❗️ ▶️ 2 🍇
51-
↩️
62+
↩️ 🆕⏹⏫❗
5263
🍉
5364

5465
↪️ 🐔 children❗️ ▶️ 0 🍇
@@ -59,6 +70,7 @@
5970
🙅 🍇
6071
😀 🔡 id 10❗️❗️
6172
🍉
73+
↩️ 🤷‍♀️
6274
🍉
6375

6476
📗 Depth-First Search Stack 📗
@@ -116,7 +128,16 @@
116128
😀 🔤🏢 - Breadth-First Search Queue🔤❗️
117129
🏢tree❗️
118130

131+
😀 🔤🍭 - Depth-First Search Recursive Inorder Binary - Error🔤❗️
132+
💭 Calling the Depth-First Search Recursive Inorder Binary method here does
133+
💭 result in an error, since "tree" is not a binary tree.
134+
️↪️ 🍭tree❗️ ➡️ return 🍇
135+
😀 🔡return❗❗️️
136+
🍉
137+
119138
🆕🌲🆕 3 2❗️ ➡️ binary_tree
120139
😀 🔤🍭 - Depth-First Search Recursive Inorder Binary🔤❗️
121-
🍭binary_tree❗️
140+
️↪️ 🍭binary_tree❗️ ➡️ return 🍇
141+
😀 🔡return❗❗️️
142+
🍉
122143
🍉

0 commit comments

Comments
 (0)