Chapter 04 — Speeding Up Your Code with Big O

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/26

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 7:32 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

27 Terms

1
New cards
Big O as a practical tool
Big O helps identify slow algorithms and decide when code should be optimized
2
New cards
Speeding up code
Improving an algorithm so it takes fewer steps as input grows
3
New cards
Bubble Sort
A sorting algorithm that compares neighboring values and swaps them if they are out of order
4
New cards
How Bubble Sort works
It repeatedly compares adjacent values and swaps them until the array is sorted
5
New cards
Comparison
Checking two values to see which should come first
6
New cards
Swap
Switching two values’ positions in an array
7
New cards
Pass-through
One full scan through part of the array during sorting
8
New cards
Why it is called Bubble Sort
Larger values gradually bubble up to the end of the array
9
New cards
Sorted flag
A boolean value used to track whether the array is fully sorted
10
New cards
Unsorted until index
The rightmost index that still needs to be checked during Bubble Sort
11
New cards
Bubble Sort stopping condition
The algorithm stops after a full pass-through with no swaps
12
New cards
Bubble Sort comparisons
Bubble Sort compares neighboring pairs of values
13
New cards
Bubble Sort swaps
Bubble Sort swaps neighboring values when they are out of order
14
New cards
Bubble Sort worst case
When the array is sorted in reverse order
15
New cards
Bubble Sort Big O
O(N²)
16
New cards
Why Bubble Sort is O(N²)
It makes many comparisons and swaps across multiple pass-throughs
17
New cards
O(N²)
Quadratic time; the number of steps grows roughly with N squared
18
New cards
Quadratic time
A slow growth pattern where doubling the input can create about four times the work
19
New cards
Nested loops
Loops inside other loops, often leading to O(N²)
20
New cards
Duplicate checking with nested loops
O(N²), because each value may be compared with every other value
21
New cards
Quadratic problem
A problem solved slowly because it compares many pairs of values
22
New cards
Linear solution
A faster solution that processes each item once
23
New cards
Faster duplicate checking
Track existing values in another structure to avoid comparing every pair
24
New cards
existingNumbers array
An extra array used to remember which numbers have already appeared
25
New cards
Time-space tradeoff
Using more memory to make an algorithm faster
26
New cards
O(N²) to O(N) improvement
Replacing nested comparisons with a single loop and extra storage
27
New cards
Main lesson of Chapter 04
Big O helps reveal slow O(N²) patterns and guides you toward faster solutio