Design Analysis R1

0.0(0)
Studied by 0 people
call kaiCall Kai
Locked
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/114

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 3:21 PM on 9/15/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

115 Terms

1
New cards

What is an algorithm?

A well-defined computational procedure that takes input, performs a finite sequence of steps, and produces output.

2
New cards

What are the two main issues related to algorithms?

How to design algorithms and how to analyze their efficiency.

3
New cards

What resources can algorithm analysis consider?

Time, memory, communication bandwidth, energy, and other computational resources.

4
New cards

What is a data structure?

A scheme for organizing related data so it can be accessed and modified efficiently.

5
New cards

What is an array?

A sequence of same-type items stored contiguously in memory and accessed by index.

6
New cards

What is a linked list?

A sequence of nodes containing data and one or more links or pointers to other nodes.

7
New cards

What does LIFO mean?

Last In, First Out; the behavior of a stack.

8
New cards

What operations are associated with a stack?

Push inserts at the top and pop removes from the top.

9
New cards

What does FIFO mean?

First In, First Out; the behavior of a queue.

10
New cards

What operations are associated with a queue?

Enqueue adds at the rear and dequeue removes from the front.

11
New cards

What is a priority queue?

A structure that supports inserting items and accessing/removing the highest-priority item.

12
New cards

What structure commonly implements a priority queue efficiently?

A heap.

13
New cards

What is a graph G=(V,E)?

A set V of vertices and a set E of edges connecting pairs of vertices.

14
New cards

What is an undirected edge?

An edge where (u,v) is equivalent to (v,u).

15
New cards

What is a directed edge?

An edge with direction from a tail vertex to a head vertex.

16
New cards

What is a weighted graph?

A graph whose edges have numerical weights or costs.

17
New cards

What are the two common graph representations?

Adjacency matrix and adjacency list.

18
New cards

What is a cycle?

A positive-length path that starts and ends at the same vertex without traversing the same edge more than once.

19
New cards

What is an acyclic graph?

A graph containing no cycles.

20
New cards

What is a tree?

A connected acyclic graph.

21
New cards

What is a forest?

An acyclic graph whose connected components are trees.

22
New cards

What is input size?

A parameter measuring how large an algorithm's input is, such as n elements or |V| and |E| for a graph.

23
New cards

What is an algorithm's basic operation?

The operation that contributes most to running time, usually because it is executed most often.

24
New cards

How is time efficiency analyzed theoretically?

By counting how many times the basic operation executes as a function of input size.

25
New cards

What is worst-case analysis?

The maximum number of basic operations over all inputs of size n.

26
New cards

What is best-case analysis?

The minimum number of basic operations over all inputs of size n.

27
New cards

What is average-case analysis?

The expected number of basic operations over inputs of size n under an assumed probability distribution.

28
New cards

Is average case the average of best and worst case?

No. It is an expected value based on a probability model for inputs.

29
New cards

Why is worst-case analysis important?

It provides an upper bound and is often easier and more useful to guarantee.

30
New cards

Insertion sort best-case complexity?

Theta(n), when the input is already sorted.

31
New cards

Insertion sort worst-case complexity?

Theta(n^2), such as reverse-sorted input.

32
New cards

Insertion sort average-case complexity?

Theta(n^2).

33
New cards

Sequential search best case?

1 comparison.

34
New cards

Sequential search worst case?

n comparisons, Theta(n).

35
New cards

Average successful comparisons for sequential search when positions are equally likely?

(n+1)/2.

36
New cards

Maximum-element scan complexity?

Theta(n), with n-1 comparisons.

37
New cards

Element uniqueness by comparing all pairs complexity?

Theta(n^2).

38
New cards

Number of unordered pairs among n items?

n(n-1)/2.

39
New cards

Standard matrix multiplication complexity?

Theta(n^3).

40
New cards

Counting binary digits by repeated division by 2 complexity?

Theta(log n).

41
New cards

What does Big-O describe?

An asymptotic upper bound.

42
New cards

Formal Big-O condition?

f(n)

43
New cards

What does Big-Omega describe?

An asymptotic lower bound.

44
New cards

Formal Big-Omega condition?

f(n) >= c g(n) for all n >= n0 for some positive c and suitable n0.

45
New cards

What does Big-Theta describe?

A tight asymptotic bound: both an upper and lower bound.

46
New cards

Formal Big-Theta condition?

c2 g(n)

47
New cards

What does lim f(n)/g(n)=0 imply about growth?

f grows asymptotically more slowly than g.

48
New cards

What does lim f(n)/g(n)=c>0 imply?

f and g have the same order of growth, so f is Theta(g).

49
New cards

What does lim f(n)/g(n)=infinity imply?

f grows asymptotically faster than g.

50
New cards

Growth rates from slowest to fastest?

1 < log n < sqrt(n) < n < n log n < n^2 < n^3 < 2^n < n!.

51
New cards

Why can constants and lower-order terms be ignored asymptotically?

The highest-growth term dominates as n becomes large.

52
New cards

What is Stirling's formula used for?

Approximating factorial growth, n! approximately sqrt(2 pi n)(n/e)^n.

53
New cards

Complexity of a loop that increments by 1 until n?

Theta(n).

54
New cards

Complexity of a loop that increments by 2 until n?

Theta(n).

55
New cards

Complexity of a loop that doubles its variable until n?

Theta(log n).

56
New cards

Complexity of a loop that repeatedly halves n?

Theta(log n).

57
New cards

Complexity of two independent nested n loops?

Theta(n^2).

58
New cards

Complexity of n outer iterations with log n inner iterations?

Theta(n log n).

59
New cards

What is 1+2+…+n?

n(n+1)/2, which is Theta(n^2).

60
New cards

If 1+2+…+k reaches n, what is k asymptotically?

Theta(sqrt(n)).

61
New cards

What is recursion?

A technique where a function calls itself to solve a smaller instance of the same problem.

62
New cards

What is a base case?

A condition that stops further recursive calls.

63
New cards

What is a recursive case?

The part of a recursive function that reduces the problem and calls itself again.

64
New cards

What happens if recursion has no reachable base case?

The call stack can grow until a stack overflow or recursion-depth error occurs.

65
New cards

Recursive definition of factorial?

F(n)=nF(n-1), with F(0)=1.

66
New cards

Work recurrence for recursive factorial multiplications?

M(n)=M(n-1)+1 with M(0)=0.

67
New cards

Complexity of recursive factorial?

Theta(n).

68
New cards

What is memoization?

Caching results of solved subproblems to avoid repeated computation.

69
New cards

Why is naive recursive Fibonacci inefficient?

It recomputes the same subproblems many times.

70
New cards

Naive recursive Fibonacci complexity in the course?

Exponential, approximately Theta(phi^n).

71
New cards

Iterative Fibonacci complexity?

Theta(n).

72
New cards

General first step in recursive analysis?

Choose a parameter indicating input size.

73
New cards

What do you write to analyze recursive running time?

A recurrence relation with an initial condition.

74
New cards

What is backward substitution?

Repeatedly expanding a recurrence until a pattern appears and then applying the base condition.

75
New cards

Solve T(n)=T(n-1)+n, T(1)=1 asymptotically.

Theta(n^2).

76
New cards

Solve T(n)=nT(n-1), T(1)=1 asymptotically.

Theta(n!).

77
New cards

Solve T(n)=T(n/3)+1 asymptotically.

Theta(log n).

78
New cards

Solve T(n)=2T(n-1)+1 asymptotically.

Theta(2^n).

79
New cards

Tower of Hanoi recurrence?

M(n)=2M(n-1)+1 with M(1)=1.

80
New cards

Tower of Hanoi exact number of moves?

2^n - 1.

81
New cards

Tower of Hanoi complexity?

Theta(2^n).

82
New cards

What is brute force?

A straightforward strategy that directly tries possibilities or uses the simplest obvious method rather than advanced optimization.

83
New cards

Why can brute force still be useful?

It is simple, widely applicable, useful for small inputs, and provides a baseline for better methods.

84
New cards

How does selection sort work?

Repeatedly find the smallest item in the unsorted portion and swap it into the next final position.

85
New cards

Selection sort complexity?

Theta(n^2) for all input arrangements in the presented algorithm.

86
New cards

How does bubble sort work?

Repeatedly compare adjacent items and swap out-of-order pairs, bubbling large items toward the end.

87
New cards

Bubble sort complexity in the presented version?

Theta(n^2).

88
New cards

How does brute-force string matching work?

Align the pattern at each possible text position and compare characters left to right until match or mismatch.

89
New cards

Worst-case brute-force string matching complexity?

O(nm) for text length n and pattern length m.

90
New cards

Closest-pair brute-force complexity?

Theta(n^2), because every pair of points is checked.

91
New cards

What is exhaustive search?

A brute-force strategy that generates candidate solutions, evaluates them, and selects a valid or optimal one.

92
New cards

Why does exhaustive search become impractical?

The candidate set often grows exponentially or factorially.

93
New cards

How many subsets exist for n items?

2^n.

94
New cards

Exhaustive 0/1 knapsack candidate count?

2^n subsets.

95
New cards

How many permutations exist for n items?

n!.

96
New cards

Exhaustive assignment-problem candidate count?

n! assignments.

97
New cards

What is the traveling salesman problem?

Find a minimum-cost tour visiting every city once and returning to the start.

98
New cards

Why is exhaustive TSP expensive?

It considers a factorial number of city orderings.

99
New cards

What data structure does DFS use?

A stack, explicitly or through recursive calls.

100
New cards

What is the main behavior of DFS?

Explore as deeply as possible before backtracking.