Зміст курсу
Binary Search in Python
Binary Search in Python
Balloons
Imagine you have this figure:
And you want to fill this figure with balloons!
If you have 3
balloons you will need 2
columns to fill them with balloons.
If you have 6
balloons you will need 3
columns to fill them with balloons.
If you have 7
balloons you will need 3
columns to fill them with balloons(in our problem).
Now we will implement the program, which will decide how many columns you need to locate the n
number of ballons!
Look at the explanation of the task! How does it work?
Use hints if needed! Be careful with the tabulation!
Завдання
- Set while loop to work while the
left + 1
is lower thanright
. - Set the
middle
variable. Themiddle
equals the(left + right) // 2
. - Update the
left
. Theleft
equals themiddle
. - Update the
right
. Theright
equals themiddle
.
Дякуємо за ваш відгук!
Balloons
Imagine you have this figure:
And you want to fill this figure with balloons!
If you have 3
balloons you will need 2
columns to fill them with balloons.
If you have 6
balloons you will need 3
columns to fill them with balloons.
If you have 7
balloons you will need 3
columns to fill them with balloons(in our problem).
Now we will implement the program, which will decide how many columns you need to locate the n
number of ballons!
Look at the explanation of the task! How does it work?
Use hints if needed! Be careful with the tabulation!
Завдання
- Set while loop to work while the
left + 1
is lower thanright
. - Set the
middle
variable. Themiddle
equals the(left + right) // 2
. - Update the
left
. Theleft
equals themiddle
. - Update the
right
. Theright
equals themiddle
.
Дякуємо за ваш відгук!
Balloons
Imagine you have this figure:
And you want to fill this figure with balloons!
If you have 3
balloons you will need 2
columns to fill them with balloons.
If you have 6
balloons you will need 3
columns to fill them with balloons.
If you have 7
balloons you will need 3
columns to fill them with balloons(in our problem).
Now we will implement the program, which will decide how many columns you need to locate the n
number of ballons!
Look at the explanation of the task! How does it work?
Use hints if needed! Be careful with the tabulation!
Завдання
- Set while loop to work while the
left + 1
is lower thanright
. - Set the
middle
variable. Themiddle
equals the(left + right) // 2
. - Update the
left
. Theleft
equals themiddle
. - Update the
right
. Theright
equals themiddle
.
Дякуємо за ваш відгук!
Imagine you have this figure:
And you want to fill this figure with balloons!
If you have 3
balloons you will need 2
columns to fill them with balloons.
If you have 6
balloons you will need 3
columns to fill them with balloons.
If you have 7
balloons you will need 3
columns to fill them with balloons(in our problem).
Now we will implement the program, which will decide how many columns you need to locate the n
number of ballons!
Look at the explanation of the task! How does it work?
Use hints if needed! Be careful with the tabulation!
Завдання
- Set while loop to work while the
left + 1
is lower thanright
. - Set the
middle
variable. Themiddle
equals the(left + right) // 2
. - Update the
left
. Theleft
equals themiddle
. - Update the
right
. Theright
equals themiddle
.