1. Big-O notation

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/14

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

15 Terms

1
New cards

What is Big-O notation?

A way to describe how an algorithm’s runtime or space usage grows as the input size increases, focusing on the growth rate.

2
New cards

What real-world analogy is used to explain Big-O?

Video game loading screens, rating load times based on level size (e.g., O(1) is instant, O(n²) is brutal)!

3
New cards

In the RAM model, what assumptions do we make?

A single processor, unlimited memory, and every basic operation or memory access takes constant time (O(1)).

4
New cards

What does O(1) time complexity mean?

Constant time: the operation takes the same amount of time regardless of input size.

5
New cards

What does O(n) time complexity mean?

Linear time: runtime grows proportionally with the input size.

6
New cards

What does O(n²) time complexity mean?

Quadratic time: runtime grows proportional to the square of the input size, typical of nested loops.

7
New cards

What does O(2ⁿ) time complexity mean?

Exponential time: runtime doubles with each additional element, as in naive recursive subset generation.

8
New cards

Why do we ignore constants and lower-order terms in Big-O?

Because for very large inputs, constants and smaller terms become negligible in the growth rate.

9
New cards

What is amortized time complexity?

The average time per operation over a sequence of operations, smoothing out occasional costly operations (e.g., dynamic array append).

10
New cards

How does linear search leverage sorted data for optimization?

It stops early and returns None as soon as the current element exceeds the target.

11
New cards

Describe the binary search algorithm and its time complexity.

Check the middle element, then recurse or iterate on the half that could contain the target; runs in O(log n) time.

12
New cards

What’s the worst-case vs. average-case vs. amortized analysis?

Worst-case is the maximum time for any input, average-case is expected time over random inputs, amortized is average over a series of operations.

13
New cards

What is time complexity?

A Big-O measure (T(n)) of how an algorithm’s runtime scales with input size.

14
New cards

What is space complexity?

A Big-O measure (S(n)) of how an algorithm’s memory usage scales with input size.

15
New cards

Compare space complexity for reversing an array in place vs. with a copy.

In-place reversal uses O(1) extra space; reversing by copying uses O(n) extra space.