Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 097e9c6

Browse files
committedJan 13, 2025·
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent b74d7f5 commit 097e9c6

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed
 

‎data_structures/binary_tree/lowest_common_ancestor.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def create_sparse(max_node: int, parent: list[list[int]]) -> list[list[int]]:
3232
For example, consider a small tree where:
3333
- Node 1 is the root (its parent is 0),
3434
- Nodes 2 and 3 have parent 1.
35-
35+
3636
We set up the parent table for only two levels (row 0 and row 1)
3737
for max_node = 3. (Note that in practice the table has many rows.)
3838
@@ -65,7 +65,7 @@ def lowest_common_ancestor(
6565
6666
The lists `level` and `parent` must be precomputed. `level[i]` is the depth of node i,
6767
and `parent` is a sparse table where parent[0][i] is the direct parent of node i.
68-
68+
6969
>>> # Consider a simple tree:
7070
>>> # 1
7171
>>> # / \\
@@ -142,9 +142,9 @@ def main() -> None:
142142
then create the sparse table and compute several lowest common ancestors.
143143
144144
The sample tree used is:
145-
145+
146146
1
147-
/ | \
147+
/ | \
148148
2 3 4
149149
/ / \\ \\
150150
5 6 7 8
@@ -160,7 +160,7 @@ def main() -> None:
160160
- LCA(8, 8) --> 8
161161
162162
To test main() without it printing to the console, we capture the output.
163-
163+
164164
>>> import sys
165165
>>> from io import StringIO
166166
>>> backup = sys.stdout

0 commit comments

Comments
 (0)
Please sign in to comment.