Skip to content

Commit

Permalink
clarify space complexity for dfs trees (#3761)
Browse files Browse the repository at this point in the history
  • Loading branch information
reywilliams authored Dec 7, 2024
1 parent 232acfa commit f201a57
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
6 changes: 5 additions & 1 deletion articles/balanced-binary-tree.md
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,11 @@ class Solution {
### Time & Space Complexity

* Time complexity: $O(n)$
* Space complexity: $O(n)$
* Space complexity: $O(h)$
* Best Case ([balanced tree](https://www.geeksforgeeks.org/balanced-binary-tree/)): $O(log(n))$
* Worst Case ([degenerate tree](https://www.geeksforgeeks.org/introduction-to-degenerate-binary-tree/)): $O(n)$

> Where $n$ is the number of nodes in the tree and $h$ is the height of the tree.
---

Expand Down
6 changes: 5 additions & 1 deletion articles/binary-tree-diameter.md
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,11 @@ class Solution {
### Time & Space Complexity

* Time complexity: $O(n)$
* Space complexity: $O(n)$
* Space complexity: $O(h)$
* Best Case ([balanced tree](https://www.geeksforgeeks.org/balanced-binary-tree/)): $O(log(n))$
* Worst Case ([degenerate tree](https://www.geeksforgeeks.org/introduction-to-degenerate-binary-tree/)): $O(n)$

> Where $n$ is the number of nodes in the tree and $h$ is the height of the tree.

---

Expand Down
6 changes: 5 additions & 1 deletion articles/depth-of-binary-tree.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,11 @@ class Solution {
### Time & Space Complexity

* Time complexity: $O(n)$
* Space complexity: $O(n)$
* Space complexity: $O(h)$
* Best Case ([balanced tree](https://www.geeksforgeeks.org/balanced-binary-tree/)): $O(log(n))$
* Worst Case ([degenerate tree](https://www.geeksforgeeks.org/introduction-to-degenerate-binary-tree/)): $O(n)$

> Where $n$ is the number of nodes in the tree and $h$ is the height of the tree.
---

Expand Down
6 changes: 5 additions & 1 deletion articles/same-binary-tree.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,11 @@ class Solution {
### Time & Space Complexity

* Time complexity: $O(n)$
* Space complexity: $O(n)$
* Space complexity: $O(h)$
* Best Case ([balanced tree](https://www.geeksforgeeks.org/balanced-binary-tree/)): $O(log(n))$
* Worst Case ([degenerate tree](https://www.geeksforgeeks.org/introduction-to-degenerate-binary-tree/)): $O(n)$

> Where $n$ is the number of nodes in the tree and $h$ is the height of the tree.

---

Expand Down

0 comments on commit f201a57

Please sign in to comment.