Thread: binary search
View Single Post
  #11 (permalink)  
Old 01-14-2008, 08:13 PM
tranceluv tranceluv is offline
Member
 
Join Date: Jan 2008
Posts: 5
tranceluv is on a distinguished road
Quote:
Originally Posted by afsina View Post
No, binary search is used for finding an element in an already sorted array quickly. For example if you have a sorted integer array like this:
a[]={1,2,4,5,6,7,9,10,11,12,14,16,19,21,22}
binary search can find the position of "19" in only three steps. However, as you see the array is already sorted.

there are several sorting algorithms, if you want to learn ebout them, you can start with easy ones, such as selection sort, bubble sort or insertion sort. there are more complicated sort algorithms also such as quick sort, merge sort, radix sort or heap sort.

Java platform uses a modified merge sort, and qick sort for its sort facilities. There are Arrays.sort() for arrays, and Collections.sort() for Lists available. But i got that you are in the learning phase, not sur eif you want to use them.

Make a search in wikipedia about search algorithms or binary search, you can see several different implementations in various languages in the links area. Or Google it. For binary search or sort, you can also check how java is doing it by checking the source.
hey thanks alot i managed it through bubble sort alghorithm


thanks people
Reply With Quote