You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1.`separator` is a way to distinguish the nodes in a string. To illustrate its importance, consider the following encoded string "banana". How did the tree structure look like before encoding? Without the `separator`, you can't tell.
102
+
2.`separator` is a way to distinguish the nodes in a string. To illustrate its importance, consider the following encoded string "banana". How did the tree structure look like before encoding? Without the `separator`, you can't tell.
77
103
78
-
2.`encodedString` is the result of the encoding process. Returns a string representation of the tree. For example: "ba,nana,nil" represents a tree with two nodes - "ba" and "nana" - in pre-order format.
104
+
3.`nilNode` is used to identify empty children. This a necesssary piece of information to retain in order to rebuild the tree later.
79
105
80
-
3. It is interesting to note that this pre-order traversal implementation also emits `nil` values in place of absent children.
106
+
4.`encode` returns a `String` representation of the `BinaryNode`. For example: "ba,nana,nil" represents a tree with two nodes - "ba" and "nana" - in pre-order format.
81
107
82
108
## Decoding
83
109
@@ -96,28 +122,29 @@ The implementation also added a few important details:
96
122
These details will shape your `decode` operation. Here's a possible implementation:
0 commit comments