Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Sqrt(n) | Problems
Binary Search in Python
course content

Зміст курсу

Binary Search in Python

Binary Search in Python

1. Binary Search
2. Problems

Sqrt(n)

In this section, we will practice with the BS algorithm.

The first task will be to find the square root of the number.

Look at the explanation of the task! How does it work?

Use hints if needed! Be careful with the tabulation!

Let's practice!

Завдання

  1. Set condition if the x equals 0 or 1.
  2. Set the while loop to work while the left is lower or equals the right.
  3. Set condition if the square of the middle elements equals x.
  4. Set condition if the square of the middle elements is lower than x.
  5. Update the left. The left equals the middle + 1.
  6. Update the result. The result equals the middle.
  7. Update the right. The right equals the middle - 1.
  8. Test the function.

Завдання

  1. Set condition if the x equals 0 or 1.
  2. Set the while loop to work while the left is lower or equals the right.
  3. Set condition if the square of the middle elements equals x.
  4. Set condition if the square of the middle elements is lower than x.
  5. Update the left. The left equals the middle + 1.
  6. Update the result. The result equals the middle.
  7. Update the right. The right equals the middle - 1.
  8. Test the function.

Все було зрозуміло?

Секція 2. Розділ 1
toggle bottom row

Sqrt(n)

In this section, we will practice with the BS algorithm.

The first task will be to find the square root of the number.

Look at the explanation of the task! How does it work?

Use hints if needed! Be careful with the tabulation!

Let's practice!

Завдання

  1. Set condition if the x equals 0 or 1.
  2. Set the while loop to work while the left is lower or equals the right.
  3. Set condition if the square of the middle elements equals x.
  4. Set condition if the square of the middle elements is lower than x.
  5. Update the left. The left equals the middle + 1.
  6. Update the result. The result equals the middle.
  7. Update the right. The right equals the middle - 1.
  8. Test the function.

Завдання

  1. Set condition if the x equals 0 or 1.
  2. Set the while loop to work while the left is lower or equals the right.
  3. Set condition if the square of the middle elements equals x.
  4. Set condition if the square of the middle elements is lower than x.
  5. Update the left. The left equals the middle + 1.
  6. Update the result. The result equals the middle.
  7. Update the right. The right equals the middle - 1.
  8. Test the function.

Все було зрозуміло?

Секція 2. Розділ 1
toggle bottom row

Sqrt(n)

In this section, we will practice with the BS algorithm.

The first task will be to find the square root of the number.

Look at the explanation of the task! How does it work?

Use hints if needed! Be careful with the tabulation!

Let's practice!

Завдання

  1. Set condition if the x equals 0 or 1.
  2. Set the while loop to work while the left is lower or equals the right.
  3. Set condition if the square of the middle elements equals x.
  4. Set condition if the square of the middle elements is lower than x.
  5. Update the left. The left equals the middle + 1.
  6. Update the result. The result equals the middle.
  7. Update the right. The right equals the middle - 1.
  8. Test the function.

Завдання

  1. Set condition if the x equals 0 or 1.
  2. Set the while loop to work while the left is lower or equals the right.
  3. Set condition if the square of the middle elements equals x.
  4. Set condition if the square of the middle elements is lower than x.
  5. Update the left. The left equals the middle + 1.
  6. Update the result. The result equals the middle.
  7. Update the right. The right equals the middle - 1.
  8. Test the function.

Все було зрозуміло?

In this section, we will practice with the BS algorithm.

The first task will be to find the square root of the number.

Look at the explanation of the task! How does it work?

Use hints if needed! Be careful with the tabulation!

Let's practice!

Завдання

  1. Set condition if the x equals 0 or 1.
  2. Set the while loop to work while the left is lower or equals the right.
  3. Set condition if the square of the middle elements equals x.
  4. Set condition if the square of the middle elements is lower than x.
  5. Update the left. The left equals the middle + 1.
  6. Update the result. The result equals the middle.
  7. Update the right. The right equals the middle - 1.
  8. Test the function.

Секція 2. Розділ 1
Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
We're sorry to hear that something went wrong. What happened?
some-alt