Flashcards · Algorithms · Free
Algorithms flashcards, generated for you.
Example Algorithms study cards to learn from right now — then generate a full set from your own notes (plus a practice quiz) and export to Quizlet or Anki. Free, no account needed.
Example Algorithms flashcards
What is an algorithm?
A step-by-step procedure to solve a problem or compute a result. Must be finite, deterministic, and terminate.
Define time complexity and what Big-O notation represents.
Time complexity measures how runtime scales with input size n. Big-O describes worst-case upper bound—e.g., O(n²) means operations grow quadratically.
What is space complexity?
The amount of memory (RAM) an algorithm uses relative to input size n. Includes auxiliary space for variables, recursion stack, data structures.
Explain the trade-off between time and space complexity.
Optimize one at cost of the other. Caching/memoization uses extra memory to reduce repeated computation time. Hash tables use space to achieve O(1) lookup instead of O(n) search.
What distinguishes a greedy algorithm? Name one pitfall.
Makes locally optimal choice at each step without reconsidering. Pitfall: doesn't always yield global optimum. Example: coin change with denominations [1,3,4]—greedy picks 4, then fails where DP picks 3+3.
When is divide-and-conquer better than brute force? Give an example.
Divide-and-conquer recursively breaks problems into smaller subproblems. Better when subproblems overlap or structure allows combining solutions efficiently. Example: merge sort is O(n log n) vs bubble sort O(n²).
What is dynamic programming and how does it differ from memoization?
DP solves overlapping subproblems by storing results; can be top-down (memoization—recursive with caching) or bottom-up (iterative table-building). Both avoid redundant work.
Why use binary search instead of linear search? State the requirement.
Binary search is O(log n) vs linear O(n). Requirement: input array must be sorted. Each comparison eliminates half the remaining search space.
Name the fundamental trade-off between sorting algorithms.
Time vs space: quicksort is O(n log n) average, O(1) space but unstable and worst-case O(n²). Merge sort is O(n log n) guaranteed but needs O(n) extra memory and is stable.
What is the difference between P and NP problems, and why does it matter for algorithm selection?
P: solvable in polynomial time. NP: solution verifiable in polynomial time (but no known fast solver). NP-hard problems like TSP have no known polynomial solution; approximation or heuristics may be only practical option.
Make your own Algorithms study set
Flashcards for related topics
Studying Algorithms to build with AI? MindloomHQ turns it into real skills — structured courses, agent projects, and certificates.
Explore MindloomHQ →