If you don't already know this, and I am interviewing you, give up now. I especially like the graph that shows the n^2 and n relationship through experimentation. You should be able to draw that graph based off the code without a second thought.
Oh, and a hash does not use a tree search. That would be logarithmic lookup time. It uses a hash, which is constant in the best (and usually average) case but as bad as linear in the worst case.
In his defense, I fear there are far too many software engineers out there who don't know this (or who may know it in an academic sense, but never think to apply it when developing). How often do you see Java programmers just use java.util.ArrayList for every single collection of objects, even when something like HashSet or HashMap would be better suited (and if they refer to it via an interface, its usually a java.util.List, not a java.util.Collection, so its not trivial to replace it)?
Comments
TrekkyLeaper replied ago:
If you don't already know this, and I am interviewing you, give up now. I especially like the graph that shows the n^2 and n relationship through experimentation. You should be able to draw that graph based off the code without a second thought.
Oh, and a hash does not use a tree search. That would be logarithmic lookup time. It uses a hash, which is constant in the best (and usually average) case but as bad as linear in the worst case.
nightwind replied ago:
Don't be too harsh, obviously this is a fresh CS student exploring data structures. :)
Nick Brown replied ago:
In his defense, I fear there are far too many software engineers out there who don't know this (or who may know it in an academic sense, but never think to apply it when developing). How often do you see Java programmers just use java.util.ArrayList for every single collection of objects, even when something like HashSet or HashMap would be better suited (and if they refer to it via an interface, its usually a java.util.List, not a java.util.Collection, so its not trivial to replace it)?
Macbeth replied ago:
OK.. I wrote him an email and now he fixed the mistake with the tree structure.
Voters For This Link (9)
Voters Against This Link (13)