Зміст курсу
Binary Search in Python
Binary Search in Python
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!
Завдання
- Set the
middle
variable. Themiddle
equals theleft + (right - left)//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]
. - Set condition if the left element is greater than the middle element.
- Perform the recursion with the left part of the array.
- Perform the recursion with the right part of the array.
- Test the function.
Дякуємо за ваш відгук!
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!
Завдання
- Set the
middle
variable. Themiddle
equals theleft + (right - left)//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]
. - Set condition if the left element is greater than the middle element.
- Perform the recursion with the left part of the array.
- Perform the recursion with the right part of the array.
- Test the function.
Дякуємо за ваш відгук!
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!
Завдання
- Set the
middle
variable. Themiddle
equals theleft + (right - left)//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]
. - Set condition if the left element is greater than the middle element.
- Perform the recursion with the left part of the array.
- Perform the recursion with the right part of the array.
- Test the function.
Дякуємо за ваш відгук!
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!
Завдання
- Set the
middle
variable. Themiddle
equals theleft + (right - left)//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]
. - Set condition if the left element is greater than the middle element.
- Perform the recursion with the left part of the array.
- Perform the recursion with the right part of the array.
- Test the function.