0
Who understand the binary search? Help me
biary search
5 odpowiedzi
+ 16
Binary search?
+ 3
I will try to simplify
1,2,3,4,5,6,7,8,9,10
suppose it is the data, where you want to search a value of 7.
so in binary search technique, look in the half of length of the data(length of data/2)... so its 5. now you see that 5 is smaller than the the value you are looking for. so it must exist in somewhere in the next numbers. Now you repeat the process, I.e. now the data you should look for is -
6,7,8,9,10
again take half like its 8, so again you compare the 8 with the value you are looking for. so its smaller(7<8). now it must be in somewhere backward. so now the data you should look for is--
6,7,8
again you take the half, its 7.. bingo 7=7.
now you find your value in 3 comparison..
in simple search you would have compare all values with 7. its like searching a word in the dictionary, where all words are alphabetically sorted. by binary search you can't find a value which is like it - 1,5,7,9,3. it have to be like this - 1,3,5,7,9
0
can you help me?
0
yes