Binary Search
This is a story why I write this algorithm again.
In this days, I work as an intern for Alibaba. To be honest, it totally a bad time for the beginning days. More awful fact to me is that my mentor do his job mostly in Java and I have to pick it up as quickly as possible. It’s totally a stranger for me about Java. What I have to say is that thanks god and my mentor. He is so nice and never blame me for my problem. You know that I suffer pressure heavily for I learned nothing but time wasted in this two weeks. I asked for help from human resource manager and hope to find someone guide me to walk out this shadow. Bo who is my mentor. He understand me and know my feeling. Bo encourage me and try to let me believe things will be better. Today, I face to a problem which I think is very naive but I didn’t show the solution to a leader of a department very well. And I could feel that he doubt about my ability in programming. I feel shame about he ask me that “Do you have programming in C or C++ for ten thousand lines ?”.
Ok, the story is end and it don’t important to me anymore. What should I do is to pay attention to my weak ability and work hard to make me more stronger. Then I will prepare for the coming recruitment in autumn.
This is a classical question. How to find an element in sequenced data ? The solution is Binary Search
. It’s the quickest way to find element in sorted data set.
The theory about Binary Search
show in blew picture.
Here you could see my code and show you how to implement a Binary Search in C++, Java and Python.
|
|
You could also find the other implementation follow this link:
Photo by Jason Leaster, Hangzhou, China
作者: Jason Leaster
来源: http://jasonleaster.github.io
链接: http://jasonleaster.github.io/2015/07/24/binary-search/
本文采用知识共享署名-非商业性使用 4.0 国际许可协议进行许可