문제

I'm in a data structures course right now and we learned about 2-3-4 trees and splay trees. I was wondering in what circumstances would you use a 2-3-4 tree instead of a splay tree? They're both self balancing and sorted so I don't see that much of a difference between them.

도움이 되었습니까?

해결책

A 2-3-4 tree only changes the structure on insertions and deletions, while a splay-tree also re-organizes the nodes on searches.

Splay trees will, thanks to the re-organization on lookup, provide faster responses if your typical usage pattern happens to look up a small subset of elements most of the time.

It is possible to implement a 2-3-4 tree such that the smallest element can be looked up in O(1), but generally both offer insertion and deletion at amortized O(log n).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top