kri shan wrote:What is the difference between HashMap(stores key/value pair) and Binary Sort ?
These are two completely unrelated things. One is a collection. The other is a algorithm. And the collection doesn't have any relationship whatsoever with that algorithm.
Which only works if they are sorted. This is a requirement of binary sort itself. Arrays.sort can help you with that.
There are also similar methods in java.util.Collections for Lists.
You're question is sort of like asking 'what is the difference between a house and a cookie recipe. One IS something, the other is a list of directions on HOW TO ACCOMPLISH something.
a HashMap is a structure with some well defined properties.
a Binary Sort is a way to get a bunch of things sorted - there are dozens of ways you COULD get things sorted, but this one works pretty well in many cases.
Wait a minute, first you were talking about binary sort, and then you were asking about binary search.
What are you looking for exactly? A tree sort algorithm? Or do you have a collection that's already sorted, and you want to do a binary search to find an element in the collection?
This message was edited 1 time. Last update was at by Jesper Young