@@ -169,37 +169,34 @@ maxnode(node::Nothing) = nothing
169169function prevnext (tree:: BinaryTree , k)
170170 prev, next = nothing , nothing
171171 current = root (tree)
172- # Traverse from the root to the target node, updating candidates.
172+ # traverse from the root to the target node, updating candidates
173173 while ! isnothing (current) && key (current) != k
174174 if k < key (current)
175175 # current is a potential next (successor)
176176 next = current
177177 current = left (current)
178- else # k.key > current. key
178+ else # k > key(current)
179179 # current is a potential previous (predecessor)
180180 prev = current
181181 current = right (current)
182182 end
183183 end
184184
185- # If the node wasn't found, return the best candidate values
185+ # if the node wasn't found, return the best candidate values
186186 if isnothing (current)
187187 return (prev, next)
188188 end
189189
190- # Found the node with key equal to x.key.
191- # Now, if there is a left subtree, the true previous (predecessor) is the maximum in that subtree.
190+ # if there is a left subtree, the true previous (predecessor) is the maximum in that subtree
192191 if ! isnothing (left (current))
193192 prev = maxnode (left (current))
194193 end
195- # Similarly , if there is a right subtree, the true next (successor) is the minimum in that subtree.
194+ # similarly , if there is a right subtree, the true next (successor) is the minimum in that subtree
196195 if ! isnothing (right (current))
197196 next = minnode (right (current))
198197 end
199198
200199 (prev, next)
201200end
202201
203- function prevnext (tree:: BinaryTree , k:: Nothing )
204- (nothing , nothing )
205- end
202+ prevnext (tree:: BinaryTree , k:: Nothing ) = (nothing , nothing )
0 commit comments