Drill 19: Rewrite it โ Complexity and Big O
Rewrite the example in your own words or structure.
What you will be able to do
- Rewrite the example in your own words or structure.
Practice task
Rewrite the example in your own words or structure.
// O(n): one pass
function total(values) {
let sum = 0
for (const value of values) sum += value
return sum
}
// O(n^2): compare every pair
function hasDuplicate(values) {
for (let i = 0; i < values.length; i++)
for (let j = i + 1; j < values.length; j++)
if (values[i] === values[j]) return true
return false
}Your turn
EasyWrite your answer
Rewrite the example in your own words or structure.
TEXT ยท starter
Your answerโฆStudy tools
Make it yours.
Keep a private note for this lesson, then turn the key ideas into flashcards you can revisit.
Sign in to save notes and flashcards.Both are private to your account and stay with your progress.
Sign inFinished reading?
Lock in what you just learned.
0%
Mark this lesson complete to save your place and move one step closer to the certificate.