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

✨ Add Threaded Binary Tree Implementation #42

Open
Kalkwst opened this issue Jan 14, 2023 · 0 comments
Open

✨ Add Threaded Binary Tree Implementation #42

Kalkwst opened this issue Jan 14, 2023 · 0 comments

Comments

@Kalkwst
Copy link
Owner

Kalkwst commented Jan 14, 2023

A threaded binary tree is a type of binary tree where each node has a "thread" that links to its in-order predecessor or successor. This allows for efficient traversal of the tree in an in-order sequence without the need for recursion or stack. This can be useful in situations where in-order traversal of the tree is frequently required and the overhead of recursion or stack usage is not desirable.

From a more technical perspective, a threaded binary tree is a variation of a binary tree where each node has a left and right pointer, as in a regular binary tree, but also has a "thread" flag that indicates if the pointer is a child or a thread. The threads link a node to its in-order predecessor or successor, allowing for efficient traversal of the tree in an in-order sequence without the need for recursion or stack. The use of threads also makes it possible to traverse the tree using only a single pointer, which can be useful in situations where memory is limited. The time complexity for traversing the tree is O(n) where n is the number of nodes in the tree, which is faster than the O(n log n) of a regular binary tree traversal.

@Kalkwst Kalkwst mentioned this issue Jan 14, 2023
26 tasks
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