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

Contenido del Curso

Binary Search in Python

Binary Search in Python

1. Binary Search
2. Problems

book
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!

Tarea

Swipe to start coding

  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.

Solución

Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 2. Capítulo 1
toggle bottom row

book
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!

Tarea

Swipe to start coding

  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.

Solución

Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 2. Capítulo 1
Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
Lamentamos que algo salió mal. ¿Qué pasó?
some-alt