Binary Search in Python: Integer Square Root

Опубликовано: 22 Июль 2018
на канале: LucidProgramming
8,820
144

In this video, we will be writing a function that computes the integer square root of a given number as input without using any built-in square root function.

Specifically, write a function that takes a non-negative integer and returns the largest integer whose square is less than or equal to
the integer given:

Example:

Assume input is integer 300.

Then the expected output of the function should be 17 since 17 squared is 289 which is strictly less than 300. Note that 18 squared is 324 which is strictly greater than 300, so the number 17 is the correct response.

This video is one part of the Binary Search playlist on my channel. For more videos on binary search and how to apply it to various problems, check out the other videos:
   • Binary Search  

The software written in this video is available at:
https://github.com/vprusso/youtube_tu...

Do you like the development environment I'm using in this video? It's a customized version of vim that's enhanced for Python development. If you want to see how I set up my vim, I have a series on this here:
http://bit.ly/lp_vim

If you've found this video helpful and want to stay up-to-date with the latest videos posted on this channel, please subscribe:
http://bit.ly/lp_subscribe


Смотрите видео Binary Search in Python: Integer Square Root онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь LucidProgramming 22 Июль 2018, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 8,820 раз и оно понравилось 144 людям.