Skip to content

getCommonAncestor(el1, el2)复杂度 #5

Description

@runshenzhu

ml.js 中 function getCommonAncestor(el1, el2)函数
两个节点先求深度,深度大的向上走到深度小的节点同一深度。。。然后两个节点一起往上走,直到相遇。这样算法复杂度是否能小一点?
每次contains判断,(貌似)需要遍历整个子树,增加不必要的开销。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions