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

Contenido del Curso

Binary Search in Python

Binary Search in Python

1. Binary Search
2. Problems

Mountain Peak

Have you ever been to the mountains? If not, I hope you still have a chance!

Imagine we have the array with the height of a mountain at specific points. And we need to find the peak value of the mountain in this array.

The peak means that points to the left and right are less than the peak point.

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

Use hints if needed! Be careful with the tabulation!

Tarea

  1. Set the middle variable. The middle equals the left + (right - left)//2.
  2. Set condition if the right and the left elements are lower or equal to the middle element. The left element: arr[middle - 1]. The right element: arr[middle + 1].
  3. Set condition if the left element is greater than the middle element.
  4. Perform the recursion with the left part of the array.
  5. Perform the recursion with the right part of the array.
  6. Test the function.

Tarea

  1. Set the middle variable. The middle equals the left + (right - left)//2.
  2. Set condition if the right and the left elements are lower or equal to the middle element. The left element: arr[middle - 1]. The right element: arr[middle + 1].
  3. Set condition if the left element is greater than the middle element.
  4. Perform the recursion with the left part of the array.
  5. Perform the recursion with the right part of the array.
  6. Test the function.

Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones

¿Todo estuvo claro?

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

Mountain Peak

Have you ever been to the mountains? If not, I hope you still have a chance!

Imagine we have the array with the height of a mountain at specific points. And we need to find the peak value of the mountain in this array.

The peak means that points to the left and right are less than the peak point.

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

Use hints if needed! Be careful with the tabulation!

Tarea

  1. Set the middle variable. The middle equals the left + (right - left)//2.
  2. Set condition if the right and the left elements are lower or equal to the middle element. The left element: arr[middle - 1]. The right element: arr[middle + 1].
  3. Set condition if the left element is greater than the middle element.
  4. Perform the recursion with the left part of the array.
  5. Perform the recursion with the right part of the array.
  6. Test the function.

Tarea

  1. Set the middle variable. The middle equals the left + (right - left)//2.
  2. Set condition if the right and the left elements are lower or equal to the middle element. The left element: arr[middle - 1]. The right element: arr[middle + 1].
  3. Set condition if the left element is greater than the middle element.
  4. Perform the recursion with the left part of the array.
  5. Perform the recursion with the right part of the array.
  6. Test the function.

Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones

¿Todo estuvo claro?

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

Mountain Peak

Have you ever been to the mountains? If not, I hope you still have a chance!

Imagine we have the array with the height of a mountain at specific points. And we need to find the peak value of the mountain in this array.

The peak means that points to the left and right are less than the peak point.

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

Use hints if needed! Be careful with the tabulation!

Tarea

  1. Set the middle variable. The middle equals the left + (right - left)//2.
  2. Set condition if the right and the left elements are lower or equal to the middle element. The left element: arr[middle - 1]. The right element: arr[middle + 1].
  3. Set condition if the left element is greater than the middle element.
  4. Perform the recursion with the left part of the array.
  5. Perform the recursion with the right part of the array.
  6. Test the function.

Tarea

  1. Set the middle variable. The middle equals the left + (right - left)//2.
  2. Set condition if the right and the left elements are lower or equal to the middle element. The left element: arr[middle - 1]. The right element: arr[middle + 1].
  3. Set condition if the left element is greater than the middle element.
  4. Perform the recursion with the left part of the array.
  5. Perform the recursion with the right part of the array.
  6. Test the function.

Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones

¿Todo estuvo claro?

Have you ever been to the mountains? If not, I hope you still have a chance!

Imagine we have the array with the height of a mountain at specific points. And we need to find the peak value of the mountain in this array.

The peak means that points to the left and right are less than the peak point.

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

Use hints if needed! Be careful with the tabulation!

Tarea

  1. Set the middle variable. The middle equals the left + (right - left)//2.
  2. Set condition if the right and the left elements are lower or equal to the middle element. The left element: arr[middle - 1]. The right element: arr[middle + 1].
  3. Set condition if the left element is greater than the middle element.
  4. Perform the recursion with the left part of the array.
  5. Perform the recursion with the right part of the array.
  6. Test the function.

Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
Sección 2. Capítulo 3
Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
We're sorry to hear that something went wrong. What happened?
some-alt