what is an assignment statement
any statement where a value is set or updated
- fewer assignment statements mean higher efficiency
what is tractability
tractability refers to how feasible it is to solve a problem efficiently as the input size grows
best to worst functions
O(1) – Constant time
O(log n) – Logarithmic time
O(n) – Linear time
O(n log n) – Log-linear time
O(n^k) – Polynomial time
O(2ⁿ) – Exponential time
O(n!) – Factorial time
rules for big O notation
what is big O notation
why do we use big O
O(1) - Constant time complexity
O(logn) - logarithmic time complexity
O(n) - linear time complexity
O(n log n) - Linearithmic Time
O(n²) - Quadratic Time
O(2^n) - Exponential Time
O(n!) - Factorial Time
time complexity for a hash table
Inserting, Deleting, and Searching: O(1)
- (O(n) in the worst case due to collisions)
time complexity for an array
time complexity for queues and stacks
linked list time complexity
binary tree time complexity
Searching, Insertion, and Deletion: O(log n) on average, but O(n) in the worst case (if the tree becomes unbalanced)
time complexity for sorting algorithms
Bubble Sort: O(n²)
Merge Sort: O(n log n)
Quick Sort: O(n log n) on average (but O(n²) in the worst case)
why is big O important
-
what is algorithmic complexity
How much time or resources an algorithm needs as the size of the input increases.
what are hardware constraints
when the physical hardware of a computer can limit how fast or how much data can be processed.
what is a tractable algorithm?
what is an intractable problem
A problem is called tractable if it can be solved in polynomial time or better
An intractable problem is one that CAN BE SOLVED, just not in polynomial time
example of an intractable problem
The Traveling Salesman Problem (TSP) – Given a set of cities and the distances between them, the problem is to find the shortest route that visits each city and returns to the starting point. The time complexity is O(n!), making it an intractable problem.