binary trees in algorithms
Same node can 开发者_开发技巧repeat in binary tree for example 1,2,3,4,1,2,3 what would happen to the repeated nodes in above example?
It would depend on the implementation of the tree. If you wanted to preserve duplicates, you could implement it to keep a linked list of data items at each node. Many implementations simply ignore the issue and "collapse" duplicates.
Depends upon the conditions you set. If small values are inserted to the left and larger or equal values to the right, equal numbers will end up on the right.
e.g.
1
\
2
\
3
\
4
/
1
\
2
\
3
if you had 1,1,1,2,3 This would be the result
1
\
1
\
1
\
2
\
3
Nothing will be on the left as the condition of >= places the nodes to the right.
精彩评论