2 - Numbers and sequence Flashcards

1
Q

What is an Abstract Data Type (ADT)?

A

An Abstract Data Type is a high-level specification that defines the collection of allowed values and the operations that can be performed on those values within a data structure, without concerning itself with implementation details.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are real numbers

A

Real numbers are numbers that can be represented in decimal form with either finite or infinite numbers after the decimal point.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are natural numbers?

A

Natural numbers are non-negative numbers starting from 0 and counting upwards infinitely: 0, 1, 2, 3, and so on.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the typical format for assignments in M269 when writing algorithms in English?

A

Assignments in M269 English-style algorithms are typically written as:

“let variable be expression.”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How can you display the value of an expression in an English-style algorithm?

A

To display the value of an expression in an English-style algorithm, you can use the instruction: “print expression.”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What defines an algorithm with constant complexity?

A

Algorithms with constant complexity are those where the runtime does not grow with increasing input values.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How is “complexity” defined in the context of algorithms?

A

Complexity, in the context of algorithms, measures the algorithm’s growth rate of runtime for ever-increasing inputs when executed in the same environment (e.g., operating system and hardware).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What does complexity focus on in terms of algorithm performance?

A

Complexity is not about how fast an algorithm runs but is a measure of how it runs for different input sizes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Why are arithmetic instructions considered to have constant complexity in the context of modern processors?

A

Modern processors can perform arithmetic operations on 64-bit numbers in a single hardware instruction, which is why arithmetic instructions are considered to have constant complexity. This means that for any number, regardless of its size, the operation will always take the same amount of time.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

When dealing with algorithm analysis, what can be assumed about assignments and return statements in terms of complexity?

A

It is assumed that assignments and return statements have a constant complexity.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How does an algorithm with a fixed number of operations, each with constant complexity, behave in terms of complexity?

A

An algorithm with a fixed number of operations, each with constant complexity, will itself have a constant complexity.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How is Big-Theta notation used in algorithm analysis?

A

Big-Theta notation is used to concisely and precisely state the complexity of an algorithm.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What does Θ(1) represent in Big-Theta notation when describing the complexity of an algorithm?

A

In Big-Theta notation, Θ(1) represents an algorithm with constant complexity, which means it has a runtime that doesn’t depend on the size of the input.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How can we express an algorithm with constant complexity in terms of Big-Theta notation?

A

An algorithm with constant complexity is expressed using Big-Theta notation as:

It has complexity Θ(1).
It takes Θ(1) time.
Its run-time is Θ(1).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What characterizes an algorithm with linear complexity?

A

An algorithm with linear complexity grows in proportion to the size of its inputs, meaning that its runtime increases as the input size increases.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How is the size of an integer represented in the context of M269 algorithm analysis?

A

In M269 algorithm analysis, the size of an integer is represented as │n│, which is the number of its decimal digits. For example, │102│ = 3.

17
Q

How is the complexity of an algorithm with linear time expressed using Big-Theta notation in M269?

A

The complexity of an algorithm with linear time is expressed in Big-Theta notation as

Θ(inputs that affect the algorithm’s complexity).

It indicates that the algorithm’s complexity increases in proportion to the input values that affect it.

18
Q

How is the complexity of the exponentiation algorithm (x^y) described in terms of Big-Theta notation?

A

The complexity of the exponentiation algorithm (x^y) is expressed as Θ(y). This is because the time it takes to compute the exponentiation depends on the value of y, where y represents how many multiplication operations will be carried out.

19
Q

In algorithm analysis, how is the complexity of an algorithm determined by the inputs provided, and what notation is used to express this complexity?

A

The complexity of an algorithm in algorithm analysis can be either independent of the inputs, resulting in constant complexity Θ(1), or dependent on the inputs themselves. In cases where complexity is influenced by the inputs, it is crucial to represent the inputs affecting the complexity using Big-Theta notation.

20
Q

What is the difference between the size and value of an integer?

A

The size of an integer refers to the number of digits the integer is made up of and is expressed as |input| in M269. The value of an integer, on the other hand, refers to the actual numerical value of the integer.

21
Q

How can confusing the size and value of an integer lead to errors in algorithm analysis?

A

Confusing the size and value of an integer can lead to errors in algorithm analysis, as exemplified when assuming the complexity of 𝑥𝑦 is Θ(│y│). This incorrect assumption can lead to misunderstandings of how computation time scales, especially in cases like 𝑥22 versus 𝑥2. The complexity of exponentiation is correctly expressed as linear in the value (not the size) of the exponent, i.e., Θ(y) rather than Θ(│y│).

22
Q

Why is it important to use variables in expressions when measuring their execution time in algorithm analysis?

A

Using variables in expressions is crucial when measuring execution time because literals in an expression are unchanging, and the compiler can optimize the evaluation of the expression by storing the solution in memory.

When timing, this optimization masks the true run-time of the algorithm. However, when variables are used, the compiler cannot make this optimization, revealing the actual run-time of the algorithm.