AlixPartners live coding Flashcards
(13 cards)
¿Qué significa O(1)?
Tiempo constante. La operación siempre toma el mismo tiempo, sin importar el tamaño de la entrada.
Ej: return arr[0];
¿Qué significa O(n)?
Tiempo lineal. El tiempo crece proporcional al tamaño de la entrada.
Ej: for (let i = 0; i < arr.length; i++)
What does O(1) mean?
Constant time. The operation always takes the same amount of time, regardless of input size.
Example: return arr[0];
What does O(n) mean?
Linear time. Time grows proportionally with input size.
Example: for (let i = 0; i < arr.length; i++)
What does O(n²) mean?
Quadratic time. Two nested loops. Time increases rapidly with input size.
Example: for (i) { for (j) {} }
What does O(log n) mean?
Logarithmic time. Cuts the problem in half each step.
Example: Binary search.
What does O(n log n) mean?
Linearithmic time. Common in efficient sorting algorithms.
Example: Merge Sort, average-case Quick Sort.
What does O(√n) mean?
Square root time. Often used in prime checking or divisor loops.
Example: for (i = 2; i <= sqrt(n); i++)
What does O(2ⁿ) mean?
Exponential time. Very slow. Often from recursive branching.
Example: Naive recursive Fibonacci
What does O(n!) mean?
Factorial time. Extremely slow. Seen in permutations and brute-force solutions.
Example: Generating all permutations of a list.
What does O(kn) mean?
Linear time scaled by a second factor k. Seen in problems with nested input sizes.
Example: Processing n words of length k.
What does O(V + E) mean?
Graph algorithms. V = vertices, E = edges. Total time scales with graph size.
Example: BFS or DFS traversal.
What does O(E log V) mean?
Graph algorithms using priority queues (heaps).
Example: Dijkstra’s algorithm with a min-heap.