Binary Search Algorithm in Python

preview_player
Показать описание
Here we look at Binary Search, and how it compares to linear search. Binary search works by searching at the middle value, and seeing if it's smaller or greater than the value we are searching for. It then segments the list and repeats and finishes binary search when the item is found.

I implemented the algorithm in python iteratively as a demonstration, but it can be implemented in any other language like c, c# or java and can be implemented recursively.
Рекомендации по теме
Комментарии
Автор

If you want to understand the algorithm a bit better, you can try implementing it recursively. I implemented it iteratively as i thought it was clearer.

owenthomson
Автор

In while loop condition should be left <= right

ridazouga
Автор

How to show list are dividing into parts in gui form ? 🥲

shahidgaming