Skip to content

Non-recursive methods should use flags #11

Description

@ProfessorAtomicManiac

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

enhancementNew feature or request

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions