2 research outputs found

    Constructing a Binary Tree Efficiently from Its Traversals

    No full text
    In this note we streamline an earlier algorithm for constructing a binary tree from its inorder and preorder traversals. The new algorithm is conceptually simpler than the earlier algorithms and its time complexity has a smaller constant factor. Keywords: Algorithms; Binary trees; Tree traversals. 1 Introduction Given the preorder and inorder traversals (or postorder and inorder traversals) of the nodes of a binary tree, the binary tree structure can be constructed. In the matter of fact, the construction is possible in linear time [1,4]. Recently, Xiang and Ushijima [5] have determined the constant factors of these algorithms by counting the numbers of comparision operations needed. They found out that the linear coefficient of Makinen's algorithm [4] is 3 in the best case and 5 in the worst case, and that the corresponding coefficients in the algorithm of Andersson and Carlsson [1] are 4 and 7. Moreover, Xiang and Ushijima presented a new algorithm with linear coefficient 3 both in ..

    Constructing a Binary Tree Efficiently from Its Traversals

    No full text
    In this note we streamline an earlier algorithm for constructing a binary tree from its inorder and preorder traversals. The new algorithm is conceptually simpler than the earlier algorithms and its time complexity has a smaller constant factor. Keywords: Algorithms; Binary trees; Tree traversals. 1 Introduction Given the preorder and inorder traversals #or postorder and inorder traversals# of the nodes of a binary tree, the binary tree structure can be constructed. In the matter of fact, the construction is possible in linear time #1,4#. Recently, Xiang and Ushijima #5# have determined the constant factors of these algorithms bycounting the numbers of comparision operations needed. They found out that the linear coe#cientofM#akinen's algorithm #4# is 3 in the best case and 5 in the worst case, and that the corresponding coe#cients in the algorithm of Andersson and Carlsson #1# are 4 and 7. Moreover, Xiang and Ushijima presented a new algorithm with linear coe#cient 3 both in the be..
    corecore