Drill 10: Inputs and outputs โ Complexity and Big O
Identify the inputs and outputs of the example.
What you will be able to do
- Identify the inputs and outputs of the example.
Practice task
Identify the inputs and outputs of the example.
// 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
Identify the inputs and outputs of the example.
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.