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.
Henry
David Newton
Author
Rancher
Joined: Sep 29, 2008
Posts: 12612
posted
0
One's a data structure, one's a sorting algorithm.
(Oops, thought I hit "Submit.")
kri shan
Ranch Hand
Joined: Apr 08, 2004
Posts: 1248
posted
0
Any direct API methods for binary serach in java or i have to write code for binay search in java ?
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.
Never ascribe to malice that which can be adequately explained by stupidity.
David Newton
Author
Rancher
Joined: Sep 29, 2008
Posts: 12612
posted
0
18' tall gingerbread house... sometimes a cookie recipe *is* a house!
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?