1. Home
  2. Explore
  3. Computer Science
  4. Algorithm Complexity Analysis

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Algorithm Complexity Analysis

  • 72Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Algorithms and Structures
  • spaceFlip card
  • KI knew it
  • DI didn't know it
  • ←Previous card
  • →Next card

What is an algorithm?

Tap to flipClick to flipspace

A finite sequence of instructions for solving a problem.

Or swipe the card

72 cards

  1. What is an algorithm?

    A finite sequence of instructions for solving a problem.

  2. What should an algorithm do when given an input?

    Produce the desired output for the problem it was designed to solve, within a finite time.

  3. What is the main idea of a greedy algorithm?

    It makes locally optimal choices to find a solution quickly, but that solution may not be globally optimal.

  4. What are the key steps of divide and conquer?

    Divide the problem into disjoint, non-overlapping subproblems; solve them independently; then combine their solutions.

  5. How does dynamic programming handle overlapping subproblems?

    It solves subproblems and stores their results, often in a table, so they can be reused rather than recomputed.

  6. Why may divide and conquer be inefficient for problems with overlapping subproblems?

    It can solve the same overlapping subproblem multiple times.

  7. What is a data structure?

    A way to store and organize data so algorithms can access and modify it efficiently.

  8. Which basic data structures are commonly used to implement algorithms?

    Stacks, linked lists, queues, trees, and graphs.

  9. Which specialized data structures are used in VLSI physical design?

    Linked lists of blocks, bin-based methods, neighbor pointers, and corner stitching.

  10. What VLSI physical-design task is integer linear programming used for in the lecture?

    Routing algorithms.

  11. What does time complexity measure?

    How the time required by an algorithm to solve a problem grows with the input.

  12. What does space complexity measure?

    How much memory an algorithm requires.

  13. How can complexity analysis help select between algorithms?

    It allows their time and memory requirements to be compared for a given problem.

  14. Why is space complexity important in resource management?

    An algorithm may require a large amount of memory, so its space requirements can constrain its use.

  15. Why can an algorithm’s runtime vary with its input?

    Different inputs may cause the algorithm to execute different amounts or parts of its instructions.

  16. Why is measuring runtime on a particular computer not a reliable way to compare algorithms?

    Different machines execute the same algorithm at different speeds.

  17. Why can programming-language choice affect measured runtime?

    The same algorithm can run at different speeds when implemented in different languages.

  18. What does asymptotic analysis provide for comparing algorithms?

    A way to describe growth in terms of input size without depending on a particular input, machine, or programming language.

  19. What is an algorithm’s order of growth?

    The dominant growth term that describes how its resource use scales with input size.

  20. When simplifying an expression for asymptotic growth, what is done with constant factors and lower-order terms?

    Constant factors and lower-order terms are dropped, leaving the dominant term.

  21. What is the order of growth of 2n+32n+32n+3?

    4O(n).

  22. What is the order of growth of 70nlog⁡n70n\log n70nlogn?

    O(nlog⁡n)O(n\log n)O(nlogn); the constant factor 707070 is ignored.

  23. What is the order of growth of 8n2+2n+108n^2+2n+108n2+2n+10?

    O(n2)O(n^2)O(n2); the lower-order terms and constant coefficient are ignored.

  24. What does Big-Oh notation describe?

    An asymptotic upper bound on a function’s growth.

  25. What condition establishes that f(n)=O(g(n))f(n)=O(g(n))f(n)=O(g(n))?

    There must be positive constants ccc and n0n_0n0​ such that 0≤f(n)≤cg(n)0\le f(n)\le c g(n)0≤f(n)≤cg(n) for all n≥n0n\ge n_0n≥n0​.

  26. What does Omega notation describe?

    An asymptotic lower bound on a function’s growth.

  27. What condition establishes that f(n)=Ω(g(n))f(n)=\Omega(g(n))f(n)=Ω(g(n))?

    There must be positive constants ccc and n0n_0n0​ such that cg(n)≤f(n)c g(n)\le f(n)cg(n)≤f(n) for all n≥n0n\ge n_0n≥n0​.

  28. What does Theta notation describe?

    An asymptotically tight bound: the function is bounded both above and below by constant multiples of the comparison function.

  29. When is f(n)=Θ(g(n))f(n)=\Theta(g(n))f(n)=Θ(g(n))?

    When f(n)=O(g(n))f(n)=O(g(n))f(n)=O(g(n)) and f(n)=Ω(g(n))f(n)=\Omega(g(n))f(n)=Ω(g(n)).

  30. What condition establishes that f(n)=Θ(g(n))f(n)=\Theta(g(n))f(n)=Θ(g(n))?

    There must be positive constants c1c_1c1​, c2c_2c2​, and n0n_0n0​ such that c1g(n)≤f(n)≤c2g(n)c_1g(n)\le f(n)\le c_2g(n)c1​g(n)≤f(n)≤c2​g(n) for all n≥n0n\ge n_0n≥n0​.

  31. In the lecture’s example with g(n)=n3g(n)=n^3g(n)=n3, what constants are given for an upper-bound demonstration?

    One choice is n0=1n_0=1n0​=1 with c=133c=133c=133; another is n0=10n_0=10n0​=10 with c=8.62c=8.62c=8.62.

  32. What constants are given for the lecture’s example showing a tight bound by n3n^3n3?

    c1=7c_1=7c1​=7, c2=133c_2=133c2​=133, and n0=1n_0=1n0​=1.

  33. What does O(1)O(1)O(1) time mean?

    Constant time: the runtime does not grow with input size.

  34. What does O(log⁡n)O(\log n)O(logn) time mean?

    Logarithmic time: runtime grows logarithmically with input size.

  35. What does O(n)O(n)O(n) time mean?

    Linear time: runtime grows proportionally to the input size.

  36. How does O(nlog⁡n)O(n\log n)O(nlogn) compare with O(n)O(n)O(n) as input size grows?

    O(nlog⁡n)O(n\log n)O(nlogn) grows faster and generally takes more time for sufficiently large inputs.

  37. What does O(n2)O(n^2)O(n2) time mean?

    Quadratic time: runtime grows proportionally to the square of the input size.

  38. What does O(2n)O(2^n)O(2n) time mean?

    Exponential time: runtime grows exponentially as the input size increases.

  39. Order these common growth rates from slowest to fastest: O(1)O(1)O(1), O(log⁡n)O(\log n)O(logn), O(n)O(n)O(n), O(nlog⁡n)O(n\log n)O(nlogn), O(n2)O(n^2)O(n2), and O(2n)O(2^n)O(2n).

    O(1)O(1)O(1), O(log⁡n)O(\log n)O(logn), O(n)O(n)O(n), O(nlog⁡n)O(n\log n)O(nlogn), O(n2)O(n^2)O(n2), O(2n)O(2^n)O(2n).

  40. Which example problems are described in the lecture as having exponential-time complexity?

    SAT and knapsack problems.

  41. What is the input and output of the natural-number summation algorithm?

    The input is nnn; the output is the sum of the first nnn natural numbers.

  42. Why does a loop that processes nnn elements often have a loop-condition check counted n+1n+1n+1 times?

    The condition is checked once before each of the nnn iterations and one additional time when the loop ends.

  43. In the lecture’s iterative summation example, what total operation count is given?

    f(n)=2n+3f(n)=2n+3f(n)=2n+3, which has order of growth O(n)O(n)O(n).

  44. What are the asymptotic bounds given for the iterative natural-number summation algorithm?

    It is O(n)O(n)O(n), Ω(n)\Omega(n)Ω(n), and therefore Θ(n)\Theta(n)Θ(n).

  45. How can the sum of the first nnn natural numbers be computed in constant time, according to the lecture?

    Use a direct formula rather than iterating through the numbers.

  46. What complexity is assigned to the direct-formula natural-number summation algorithm?

    O(1)O(1)O(1), Ω(1)\Omega(1)Ω(1), and Θ(1)\Theta(1)Θ(1).

  47. What is the worst-case time complexity of linear search through an array of nnn elements?

    O(n)O(n)O(n), because it may need to inspect every element.

  48. Does linear search require the array to be sorted?

    No. The lecture’s linear-search example uses an unsorted array.

  49. What prerequisite must an array meet for binary search?

    The array must be sorted.

  50. How does binary search narrow the search for a key?

    It checks a middle element and continues in the half where the key could be, repeatedly halving the search range.

  51. What is the time complexity of binary search?

    O(log⁡n)O(\log n)O(logn) (equivalently, O(log⁡2n)O(\log_2 n)O(log2​n)).

  52. In the lecture’s binary-search example, how many checks find the key 565656?

    Three checks: at the 4th, 7th, and 8th elements.

  53. What does the class PPP contain?

    Problems that can be solved by an algorithm in polynomial time, such as time proportional to nkn^knk for a constant kkk.

  54. What does the class NPNPNP represent in the lecture’s description?

    Problems for which a proposed or guessed solution can be verified in polynomial time.

  55. How does finding a solution to an NPNPNP problem differ from verifying a proposed solution?

    Finding a solution may be difficult, while a proposed solution can be checked in polynomial time.

  56. What is a polynomial-time reduction from problem AAA to problem BBB?

    A polynomial-time transformation that converts instances of AAA into instances of BBB so that solving the transformed instance provides a solution to the original instance.

  57. What does it mean for a problem to be NP-hard?

    Every problem in NPNPNP can be reduced to it in polynomial time.

  58. What condition makes a problem NP-complete?

    It must belong to NPNPNP and be NP-hard.

  59. How is the set of NP-complete problems represented in the lecture’s class diagram?

    As the intersection of NPNPNP and the NP-hard problems.

  60. What relationship does the lecture assign to linear search and sorting algorithms such as merge sort and quicksort?

    They are presented as examples of polynomial-time algorithms.

  61. Why may VLSI physical-design tools accept a non-optimal solution to an NP-hard optimization problem?

    A sufficiently good solution found in a reasonable time may be more useful than an optimal solution that takes too long for the design flow.

  62. What four approaches to NP-hard problems are listed for VLSI physical design?

    Exponential algorithms, special-case algorithms, approximation algorithms, and heuristic-driven algorithms.

  63. What strategy does the lecture describe under its exponential-algorithm approach?

    Break the problem into smaller subproblems, solve those subproblems in polynomial time, and combine their solutions using a technique intended to avoid exponential-time work.

  64. What is a special-case algorithm for an NP-hard problem?

    An algorithm that solves a restricted form of the problem more efficiently than the general case.

  65. What graph-coloring special case is described as solvable in polynomial time?

    Graph coloring with k=2k=2k=2 colors.

  66. What is the goal of an approximation algorithm?

    To find a near-optimal solution more quickly than finding the exact optimum.

  67. In the lecture’s approximation discussion, what do ϕ\phiϕ and ϕ∗\phi^*ϕ∗ represent?

    ϕ\phiϕ is the solution produced by the algorithm; ϕ∗\phi^*ϕ∗ is the optimal solution.

  68. What ratio is used in the lecture to compare an approximate solution with an optimal solution?

    ϕ/ϕ∗\phi/\phi^*ϕ/ϕ∗.

  69. How does the lecture compare accurate SPICE simulation with FineSim?

    The accurate SPICE engine takes longer but gives more accurate results; FineSim is faster but less accurate.

  70. When might a faster, less accurate simulator be preferable in VLSI design?

    For a large design when functional evaluation is sufficient and highly precise delay measurements are not required.

  71. What characterizes a heuristic-driven algorithm for an NP-hard problem?

    It aims to find a good, often near-optimal solution in a realistic time, without guaranteeing a globally optimal solution.

  72. What practical performance characteristics does the lecture attribute to heuristic-driven algorithms?

    Low time and space complexity, near-optimal solutions in a realistic time frame, and good average-case performance.

Card 1 of 72
Card 1 of 72

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent