Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

HashMap Vs Binary Sort  RSS feed

 
kri shan
Ranch Hand
Posts: 1489
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the difference between HashMap(stores key/value pair) and Binary Sort ?
 
Henry Wong
author
Sheriff
Posts: 23283
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One's a data structure, one's a sorting algorithm.

(Oops, thought I hit "Submit.")
 
kri shan
Ranch Hand
Posts: 1489
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any direct API methods for binary serach in java or i have to write code for binay search in java ?
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16026
87
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a look at Arrays.binarySearch().
 
Rob Spoor
Sheriff
Posts: 21087
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12541
48
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


18' tall gingerbread house... sometimes a cookie recipe *is* a house!
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16026
87
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!