File tree Expand file tree Collapse file tree 4 files changed +20
-4
lines changed Expand file tree Collapse file tree 4 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -526,7 +526,11 @@ class Solution {
526526### Time & Space Complexity
527527
528528* Time complexity: $O(n)$
529- * Space complexity: $O(n)$
529+ * Space complexity: $O(h)$
530+ * Best Case ([ balanced tree] ( https://www.geeksforgeeks.org/balanced-binary-tree/ ) ): $O(log(n))$
531+ * Worst Case ([ degenerate tree] ( https://www.geeksforgeeks.org/introduction-to-degenerate-binary-tree/ ) ): $O(n)$
532+
533+ > Where $n$ is the number of nodes in the tree and $h$ is the height of the tree.
530534
531535---
532536
Original file line number Diff line number Diff line change @@ -520,7 +520,11 @@ class Solution {
520520### Time & Space Complexity
521521
522522* Time complexity: $O(n)$
523- * Space complexity: $O(n)$
523+ * Space complexity: $O(h)$
524+ * Best Case ([ balanced tree] ( https://www.geeksforgeeks.org/balanced-binary-tree/ ) ): $O(log(n))$
525+ * Worst Case ([ degenerate tree] ( https://www.geeksforgeeks.org/introduction-to-degenerate-binary-tree/ ) ): $O(n)$
526+
527+ > Where $n$ is the number of nodes in the tree and $h$ is the height of the tree.
524528
525529---
526530
Original file line number Diff line number Diff line change @@ -176,7 +176,11 @@ class Solution {
176176### Time & Space Complexity
177177
178178* Time complexity: $O(n)$
179- * Space complexity: $O(n)$
179+ * Space complexity: $O(h)$
180+ * Best Case ([ balanced tree] ( https://www.geeksforgeeks.org/balanced-binary-tree/ ) ): $O(log(n))$
181+ * Worst Case ([ degenerate tree] ( https://www.geeksforgeeks.org/introduction-to-degenerate-binary-tree/ ) ): $O(n)$
182+
183+ > Where $n$ is the number of nodes in the tree and $h$ is the height of the tree.
180184
181185---
182186
Original file line number Diff line number Diff line change @@ -191,7 +191,11 @@ class Solution {
191191### Time & Space Complexity
192192
193193* Time complexity: $O(n)$
194- * Space complexity: $O(n)$
194+ * Space complexity: $O(h)$
195+ * Best Case ([ balanced tree] ( https://www.geeksforgeeks.org/balanced-binary-tree/ ) ): $O(log(n))$
196+ * Worst Case ([ degenerate tree] ( https://www.geeksforgeeks.org/introduction-to-degenerate-binary-tree/ ) ): $O(n)$
197+
198+ > Where $n$ is the number of nodes in the tree and $h$ is the height of the tree.
195199
196200---
197201
You can’t perform that action at this time.
0 commit comments