Concatenating/Merging/Joining two AVL trees

前端 未结 4 1934
有刺的猬
有刺的猬 2020-12-13 00:57

Assume that I have two AVL trees and that each element from the first tree is smaller then any element from the second tree. What is the most efficient way to concatenate th

4条回答
  •  盖世英雄少女心
    2020-12-13 01:25

    I suspect that you'll just have to walk one tree (hopefully the smaller) and individually add each of it's elements to the other tree. The AVL insert/delete operations are not designed to handle adding a whole subtree at a time.

提交回复
热议问题