In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces "how to realize the threaded binary tree of Java data structure". In the daily operation, I believe that many people have doubts about how to realize the threaded binary tree of Java data structure. Xiaobian consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubt of "how to realize the threaded binary tree of Java data structure". Next, please follow the editor to study!
1. Introduction of threaded binary tree
The sequence {1, 3, 6, 8, 10, 14} is constructed into a binary tree.
Problem analysis:
1. When we iterate through the above binary tree, the numbers are listed as {8, 3, 10, 1, 6, 14}.
two。 But the left and right pointers of 6, 8, 10, 14 nodes are not fully utilized.
3. What if we want to make full use of the left and right pointers of each node so that each node can point to its own front and back nodes?
4. Solution-threaded binary tree
Concept: when using the binary linked list as the storage structure of the binary tree, it is very convenient to find the left and right children of a node; but in general, it is impossible to directly find the predecessor and successor nodes of the node in a certain traversal sequence. Therefore, the use of threading, the use of the binary tree structure linked list of the empty pointer domain for threading.
two。 Basic characteristics of threaded binary tree
The binary linked list of n nodes contains an empty pointer domain of nong1 [formula 2n-(nmel1) = nong1]. Use the empty pointer field in the binary list to store pointers to the precursor and successor nodes of the node in a certain traversal order (this additional pointer is called a "clue").
This kind of binary linked list with clues is called cue linked list, and the corresponding binary tree is called cue binary tree (Threaded BinaryTree). According to the different properties of cues, cue binary trees can be divided into three types: pre-order cue binary tree, middle order cue binary tree and post-order cue binary tree.
3. An application case of threaded binary tree
The middle sequence lines the binary tree and traverses it
The application case shows that the following binary tree is used for the middle order clue binary tree. The number of traversal in the middle order is listed as {8, 3, 10, 1, 14, 6}
Train of thought analysis
The result of traversal in the middle order: {8, 3, 10, 1, 14, 6}
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.