Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Space complexity of BFS approach for problem 14.1 is O(n) or O(w)? #208

Open
gan3i opened this issue Jan 2, 2021 · 0 comments
Open

Space complexity of BFS approach for problem 14.1 is O(n) or O(w)? #208

gan3i opened this issue Jan 2, 2021 · 0 comments

Comments

@gan3i
Copy link

gan3i commented Jan 2, 2021

The BFS approach of is_binary_tree_bst function stores nodes in a queue but queue will never hold all the nodes at any point, so stating the space complexity as O(w) where w is the width of tree is more precise than O(n), please correct me if my understanding is wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant