Skip to content

Commit d13f9d0

Browse files
committed
Fix various typos in Threaded README
1 parent afde1e0 commit d13f9d0

File tree

1 file changed

+19
-20
lines changed

1 file changed

+19
-20
lines changed

Threaded Binary Tree/README.markdown

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ The main motivation behind using a threaded binary tree over a simpler and
1717
smaller standard binary tree is to increase the speed of an in-order traversal
1818
of the tree. An in-order traversal of a binary tree visits the nodes in the
1919
order in which they are stored, which matches the underlying ordering of a
20-
[binary search tree](../Binary Search Tree/). Thus threaded binary trees are
21-
almost always binary search trees too. The idea is to visit all the left
22-
children of a node first, then visit the node itself, and visit the left
23-
children last.
20+
[binary search tree](../Binary Search Tree/). This means most threaded binary
21+
trees are also binary search trees. The idea is to visit all the left children
22+
of a node first, then visit the node itself, and then visit the right children
23+
last.
2424

2525
An in-order traversal of any binary tree generally goes as follows (using Swift
2626
syntax):
@@ -89,25 +89,24 @@ binary search tree:
8989
![Partial](Images/Partial.png)
9090

9191
The solid lines denote the links between parents and children, while the dotted
92-
lines denote the "threads." The important thing to note here is how the
93-
children and thread edges interact with each other. Every node besides the
94-
root has one entering edge (from its parent), and two leaving edges: one to the
95-
left and one to the right. The left leaving edge goes to the node's left child
96-
if it exists, and to its in-order predecessor if it does not. The right
97-
leaving edge goes to the node's right child if it exists, and to its in-order
98-
successor if it does not. The exceptions are the left-most node and the
99-
right-most node, which do not have a predecessor or successor, respectively.
92+
lines denote the "threads." It is important to note how the children and
93+
thread edges interact with each other. Every node besides the root has one
94+
entering edge (from its parent), and two leaving edges: one to the left and one
95+
to the right. The left leaving edge goes to the node's left child if it
96+
exists, and to its in-order predecessor if it does not. The right leaving edge
97+
goes to the node's right child if it exists, and to its in-order successor if
98+
it does not. The exceptions are the left-most node and the right-most node,
99+
which do not have a predecessor or successor, respectively.
100100

101101

102102
## Representation
103103

104-
Before we go into detail about the methods that we can apply to threaded binary
105-
trees, it might be a good idea to explain how we will be representing the tree.
106-
The core of this data structure is the `ThreadedBinaryTree<T: Comparable>`
107-
class. Each instance of this class represents a node with six member
108-
variables: `value`, `parent`, `left`, `right`, `leftThread`, and
109-
`rightThread`. Of all of these, only `value` is required. The other five are
110-
Swift *optionals* (they may be `nil`).
104+
Before we go into detail about the methods of a threaded binary tree, we should
105+
first explain how the tree itself is represented. The core of this data
106+
structure is the `ThreadedBinaryTree<T: Comparable>` class. Each instance of
107+
this class represents a node with six member variables: `value`, `parent`,
108+
`left`, `right`, `leftThread`, and `rightThread`. Of all of these, only
109+
`value` is required. The other five are Swift *optionals* (they may be `nil`).
111110
- `value: T` is the value of this node (e.g. 1, 2, A, B, etc.)
112111
- `parent: ThreadedBinaryTree?` is the parent of this node
113112
- `left: ThreadedBinaryTree?` is the left child of this node
@@ -185,7 +184,7 @@ func traverseInOrderBackward(visit: T -> Void) {
185184
}
186185
}
187186
```
188-
Again, this a method of `ThreadedBinaryTree`, so we'd call it like
187+
Again, this a method of `ThreadedBinaryTree`, so we'd call it via
189188
`node.traverseInorderForward(visitFunction)`. Note that we are able to specify
190189
a function that executes on each node as they are visited. This function can
191190
be anything you want, as long as it accepts `T` (the type of the values of the

0 commit comments

Comments
 (0)