Discrete Mathematics: Chapter 4 Algorithms

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

1/22

flashcard set

Earn XP

Description and Tags

Flashcards covering key definitions, characteristics, algorithms (text search, insertion sort, recursion), and asymptotic analysis from Chapter 4: Algorithms.

Last updated 1:59 PM on 10/11/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

23 Terms

1
New cards

What is an algorithm and what are its key characteristics?

An algorithm is a finite set of instructions characterized by: input, output, precision, deterministic execution, finiteness, correctness, and generality.

2
New cards

What does the "deterministic" characteristic of an algorithm mean?

The results of each step of execution are uniquely defined and depend only on the inputs and the results of preceding steps.

3
New cards

What is a trace of an algorithm?

A trace is a simulation or trial run that checks the algorithm using specific input values.

4
New cards

In pseudocode, what does the assignment statement "x=yx = y" signify?

It means "copy the value of yy into xx".

5
New cards

For an input sequence of size nn, how many loop iterations are performed in Algorithm 4.1.2 (Finding the Maximum Value in a Sequence)?

The loop is always executed n−1n - 1 times, making the worst-case, best-case, and average-case times each equal to n−1n - 1.

6
New cards

What value does Algorithm 4.2.1 (Text Search) return if the pattern pp does not occur in text tt?

It returns 00.

7
New cards

In Algorithm 4.2.1 (Text Search), why is the outer loop upper bound set to n−m+1n - m + 1?

Because index n−m+1n - m + 1 is the last possible starting position in tt where a substring of length mm can fit.

8
New cards
<p>What algorithm and inputs are being traced in this diagram?</p>

What algorithm and inputs are being traced in this diagram?

A trace of Algorithm 4.2.1 (Text Search) searching for the pattern "001" in the text "010001", which successfully returns index i=4i = 4.

9
New cards

For what size of sequences is insertion sort considered one of the fastest sorting algorithms?

Small sequences of fewer than 5050 items.

10
New cards

What is the state of the subsequence s1,...,sis_1, \text{...}, s_i at the ii-th iteration of insertion sort?

The first part of the sequence, s1,...,sis_1, \text{...}, s_i, has been rearranged so that it is sorted.

11
New cards

What is the analysis of an algorithm?

The process of estimating the time and space needed to execute an algorithm.

12
New cards

Why is an algorithm that examines all subsets of a set of size nn impractical for large nn?

A set with nn elements has 2n2^n subsets, requiring at least 2n2^n units of time, which grows too rapidly as nn increases.

13
New cards

What are the definitions of best-case, worst-case, and average-case execution times?

Best-case time is the minimum execution time for inputs of size nn; worst-case time is the maximum execution time for inputs of size nn; and average-case time is the average execution time across inputs of size nn.

14
New cards

What is the formal definition of f(n)=O(g(n))f(n) = O(g(n))?

There exist two positive constants cc and n0n_0 such that ∣f(n)∣≤c ∣g(n)∣|f(n)| \le c\,|g(n)| for all n≥n0n \ge n_0.

15
New cards

According to the polynomial theorem for Big O, what is the asymptotic upper bound of A(n)=amnm+⋯+a1n+a0A(n) = a_m n^m + \dots + a_1 n + a_0?

A(n)=O(nm)A(n) = O(n^m).

16
New cards

What is the formal definition of the asymptotic lower bound f(n)=Ω(g(n))f(n) = \Omega(g(n))?

There exists a positive constant C2C_2 such that ∣f(n)∣≥C2 ∣g(n)∣|f(n)| \ge C_2\,|g(n)| for all but finitely many nn.

17
New cards

When is a function f(n)f(n) said to be of order Θ(g(n))\Theta(g(n))?

When f(n)f(n) is both O(g(n))O(g(n)) and Ω(g(n))\Omega(g(n)), meaning g(n)g(n) is an asymptotic tight bound for f(n)f(n).

18
New cards

Why is the expression 3n+23n + 2 not O(1)O(1)?

Because 3n+23n + 2 is not less than or equal to any constant cc for all nn.

19
New cards

What is a recursive algorithm?

An algorithm that contains a recursive function, which is a function that invokes itself.

20
New cards

What is the base case in Algorithm 4.4.2 (Computing nn Factorial)?

When n==0n == 0, where the function returns 11.

21
New cards

What recurrence relation calculates the number of ways a robot can walk n metersn\text{ meters} using only 1-meter1\text{-meter} and 2-meter2\text{-meter} steps?

walk(n)=walk(n−1)+walk(n−2)\text{walk}(n) = \text{walk}(n - 1) + \text{walk}(n - 2) for n>2n > 2, with base cases walk(1)=1\text{walk}(1) = 1 and walk(2)=2\text{walk}(2) = 2.

22
New cards

How is the Fibonacci sequence f1,f2,…f_1, f_2, \dots recursively defined?

f1=1f_1 = 1, f2=1f_2 = 1, and fn=fn−1+fn−2f_n = f_{n-1} + f_{n-2} for n>3n > 3.

23
New cards
<p>What botanical phenomenon related to Fibonacci numbers is displayed in this figure?</p>

What botanical phenomenon related to Fibonacci numbers is displayed in this figure?

Spiral phyllotaxis on a pine cone, consisting of 1313 clockwise spirals and 88 counterclockwise spirals, reflecting Fibonacci numbers that optimize seed distribution.