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!
Tehtävä
Swipe to start coding
- Set condition if the
xequals0or1. - Set the while loop to work while the
leftis lower or equals theright. - Set condition if the square of the middle elements equals
x. - Set condition if the square of the middle elements is lower than
x. - Update the
left. Theleftequals themiddle + 1. - Update the
result. Theresultequals themiddle. - Update the
right. Therightequals themiddle - 1. - Test the function.
Ratkaisu
Oliko kaikki selvää?
Kiitos palautteestasi!
Osio 2. Luku 1
single
Kysy tekoälyä
Kysy tekoälyä
Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme
Awesome!
Completion rate improved to 14.29
Sqrt(n)
Pyyhkäise näyttääksesi valikon
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!
Tehtävä
Swipe to start coding
- Set condition if the
xequals0or1. - Set the while loop to work while the
leftis lower or equals theright. - Set condition if the square of the middle elements equals
x. - Set condition if the square of the middle elements is lower than
x. - Update the
left. Theleftequals themiddle + 1. - Update the
result. Theresultequals themiddle. - Update the
right. Therightequals themiddle - 1. - Test the function.
Ratkaisu
Oliko kaikki selvää?
Kiitos palautteestasi!
Osio 2. Luku 1
single