Chapter 8 Flashcards

1
Q

What is a control structure?

A

A control statement and the statements whose execution are controlled

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

What is the most important design question for control structures?

A

Should a control structure have multiple entries

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

What does a selection statement provide?

A

A choice between 2+ execution paths

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

What are the 2 categories for selection statements?

A

2 way selectors and Multiple way selectors.

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

What is the general form of a 2 way selection statements

A

if then else

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

How are compound statements usually delimited as?

A

Square braces

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

Are statement sequences contained in blocks?

A

No.

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

To disambiguate nested selectors:

A

Match else with nearest if.
Force semantics ({})

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

What are the design issues with multiple way selectors?

A

What is the control expression’s form and type.
How are selectable segments specified.
Is execution in structure only a single selection
How are case values specified
How are unrepresented expression values handled

(switch case in c c++ Java and JS)

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

Can a if statement be a multiple way selector?

A

Yes. if elif elif elif …

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

What are the 2 types of iterative statements?

A

Iteration
Recursion

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

What are the design issues for iterative statements?

A

How are the iterations controlled
Where is the control mechanism in the loop

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

What do Counting iterative statement have?

A

Loop variable.
variables intial, terminal and stepsize values

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

What is the design issues for counter controlled loops design issues?

A

Type + scope of loop variable
Can loop variable be changed in loop body.
Should the loop parameters be evaluated only once?
What is the loop variable after the loop

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

What is logically controlled loops?

A

Repetition control using Boolean expressions

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

Which is more general? Counter or logical loops

A

Logical

17
Q

What are the design issues with logically controlled loops?

A

Should the control be pretest or posttest.
Should the loop be a special case of a count loop?

18
Q

What are user located loop control mechanisms?

A

Something like “break”

19
Q

What are iteration controlled data structures?

A

Iterations are controlled by number of elements in a data structure.

20
Q

How are iteration based structures controlled?

A

By a iterator

21
Q

What is unconditional branching?

A

Transferring control to specific place in program

22
Q

What are guarded comments?

A

If the order of evaluation is not important the program should not specify an order

23
Q

What is the form of a guarded loop?

A

do bool1->statment1
[] bool2 -> statment2
[] …
od