Chapter 2 Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What is involved in the process of program development?

A

Problem description

  • Input
  • Result (output)

Algorithm

  • Pseudocode is fine

Program

  • Java, C, Python

Machine instructions (executable)

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

How is pseudocode created?

A

It’s created from using components of natural language to express algorithms

  • Pseudocode = “Not real” Code
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are some issues with using natural language to represent algorithms?

A
  • Natural language can be extremely verbose
  • Lack of structure makes it difficult to locate specific sections of the algorithm
  • Natural language is too “rich” in interpretation and meaning
  • Not sufficiently precise to represnt algorithms
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Why is using pseudocode beneficial?

A
  • Used to design and represent algorithms
  • A compromise between the two extremes of natural and formal languages
  • Will not be unique
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Define:

Sequential Algorithm

A

Sometimes called a straight-line algorithm; the order is followed in a linear fashion.

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

Define:

Control Operations

A
  • Conditional and iterative
  • Allow us to alter the normal sequential flow of control in an algorithm
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Define:

Conditional Statements

A
  • The “question-asking” operations of an algorithm
  • If/then/else
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Define:

Loop

A
  • The repetition of a block of instructions
  • While or For loop statement
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Define:

Continuation Condition

A

Determines if statement is true or false

  • if/elif statements
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Give an example of a loop.

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

Define:

Pretest Loop

A

Continuation condition is tested at the beginning of each pass through the loop

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

Define:

Posttest Loop

A

Continuation condition is tested at the end of the loop body, not the beginning.

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

Define:

Primitives

A

Instructions that computing agent understands and is capable of executing without further explanation.

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

Define:

Pattern Matching

A
  • Process of searching for a special pattern of symbols within a larger collection of information.
  • Is assisting microbiologist and geneticists studying and mapping the human genome.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Give examples of higher-level constructs.

A
  • Sort the entire list into ascending order.
  • Attempt to match the entire pattern against the text.
  • Find a root of the equation.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Define:

Abstraction

A

Use of high-level instructions during the design process

17
Q

Define:

Top-down Design

A

Viewing an operation at a high level of abstraction

18
Q

How to test efficiency of algorithms?

A

Run Time Analysis

  • Worst Case
  • Average Case

Big Oh

  • Constant run time O(1)
  • Logarithmic run time O(logn)
  • Linear run time O(n)
  • Linearithmic run time O(nlogn)
  • Quadratic run time O(n2)
19
Q

How to test efficiency of direct sequecing algorithms?

A

For a sequence of instructions, the cost of executing the sequence of instructions is, asymptotically speaking, the same as the maximum cost of the individual instructions.

For three instructions a, b and c:

  • O({a, b, c}) = max (O(a), O(b), O(c))

where {a, b, c} represents direct sequencing of the three individual instructions.

20
Q

How to test effeciency for conditional execution algorithms?

A

For a conditional statement, the cost of execution is the maximum of the cost of evaluating the condition and the cost(s) of the alternate instruction sequences

  • O(if {condition} then {sequence1} else {sequence2}) = max (O(condition), O(sequence1), O(sequence2))
21
Q

How to test the effeciency of iterative construct algorithms?

A

Applies to an iterative construct ( e.g., loop, for, while) that will cause the execution of a subset of instructions to be repeated a specified number of times.

The trick is to understand how many times the instructions will be repeated.

For k iterations, the general rule is:

  • O(loop (k) {sequence}) = O(k*sequence)