Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getCommonAncestor(el1, el2)复杂度 #5

Open
runshenzhu opened this issue Apr 10, 2015 · 0 comments
Open

getCommonAncestor(el1, el2)复杂度 #5

runshenzhu opened this issue Apr 10, 2015 · 0 comments

Comments

@runshenzhu
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant