c - Benefit of threaded binary tree -


In the documents of threaded binary tree, I read

recursive and non-binary tree traversal For recursive procedures it is necessary that pointers to all free nodes be temporarily placed on the stack. This can be avoided by using the Threaded Binary Tree

My question is

1- How and how long is the pointers in normal binary trees?

2- How does the points in the stack in the threaded binary tree not be added?

1) They are talking about walking in the tree. You either use a recursive algorithm (which uses the CPU stack to keep track of things for you), or you use an iterative approach and keep a data structure stack and see yourself To manage the nodes. The latter can perform better because you eliminate the overhead of the function calls, but it is often more conceptually difficult to understand.

2) A threaded tree stores how to walk on a tree in the tree itself (instead of the null pointers you have to follow, they point to the next place in the tree to walk), by You get permission to run on a "straight line" tree, so no stack is required.

- A



Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -