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

Non-recursive methods should use flags #11

Open
ProfessorAtomicManiac opened this issue Oct 26, 2021 · 0 comments
Open

Non-recursive methods should use flags #11

ProfessorAtomicManiac opened this issue Oct 26, 2021 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@ProfessorAtomicManiac
Copy link
Owner

Some Iterative methods for binary tree traversal have visited nodes stored in a stack, which is bad for a number of reasons.

  1. Getting an element from a stack takes O(n) time and should be replaced by a dynamic array where getting an element from an array takes O(1) time. Generally prefer Dynamic Arrays over Linked Lists
  2. Another good replacement for a stack is to use flags where each object has a flag telling whether the object has been visited once already.
@ProfessorAtomicManiac ProfessorAtomicManiac self-assigned this Oct 26, 2021
@ProfessorAtomicManiac ProfessorAtomicManiac added the enhancement New feature or request label Oct 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant