Chapter 07 — Big O in Everyday Code

0.0(0)
Studied by 0 people
call kaiCall Kai
Locked
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/31

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 7:38 PM on 7/29/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

32 Terms

1
New cards
Big O in everyday code
Using Big O to analyze realistic code patterns
2
New cards
First Big O step
Identify what N represents
3
New cards
N in an array problem
The number of items in the array
4
New cards
N in a string problem
The number of characters in the string
5
New cards
Mean average of even numbers
O(N), because the algorithm loops through the array once
6
New cards
3N + 3 simplified
O(N), because Big O ignores constants and lower-impact extra steps
7
New cards
One loop over N items
O(N)
8
New cards
Two separate loops over N items
O(N), because N + N becomes 2N, then O(N)
9
New cards
Two nested loops over the same N items
O(N²), because N times N equals N²
10
New cards
Three nested loops over the same N items
O(N³), because N times N times N equals N³
11
New cards
Word Builder with two characters
O(N²), because it uses two nested loops
12
New cards
Word Builder with three characters
O(N³), because it uses three nested loops
13
New cards
Array sample
O(1), because it reads the first, middle, and last values no matter how large the array is
14
New cards
Fixed index access
O(1), because the number of operations stays constant
15
New cards
Average Celsius reading
O(N), because two separate loops still simplify to O(N)
16
New cards
Separate loops rule
Separate loops add, then simplify
17
New cards
Nested loops rule
Nested loops multiply
18
New cards
Nested loop with fixed inner loop
O(N), because N times a constant is still O(N)
19
New cards
Clothing labels example
O(N), because the inner loop always runs 5 times
20
New cards
Array of arrays processed once
O(N), where N is the total number of values processed
21
New cards
Count the Ones
O(N), because every number in all inner arrays is checked once
22
New cards
Palindrome checker
O(N), because checking half the string still simplifies to O(N)
23
New cards
Get all two-number products
O(N²), because the algorithm creates pairs of values
24
New cards
Shrinking inner loop
Still O(N²), because N² / 2 simplifies to O(N²)
25
New cards
Multiple datasets
Use different variables like N and M when inputs have different sizes
26
New cards
Two arrays nested loop
O(N * M), where N is the size of one array and M is the size of the other
27
New cards
Merge two sorted arrays
O(N + M), because both arrays are processed until both are finished
28
New cards
Needle in a haystack
O(N * M), where N is haystack length and M is needle length
29
New cards
Greatest product of three numbers
O(N³), because it uses three nested loops
30
New cards
Repeated halving
O(log N), because the input is cut in half each step
31
New cards
Password cracker
O(26^N), because each added character multiplies the possibilities by 26
32
New cards
Main lesson of Chapter 07
Do not just count loops; understand how often the work actually ru