HashSet class has a constant time performance for the basic operations (add, remove, contains and size).
TreeSet has log(n) time cost for the basic operations (add, remove and contains methods).
Because HashSet is constant, will it always be faster than log(n) ?
No, that's not how big-Oh works. Actual performance may differ.
Bubble sort is notoriously slow, but for a small data set it might actually perform well compared to other "better" algorithms. The big-Oh describes asymptotic behavior, not specific individual scenarios.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With