Chapter 8 Flashcards

1
Q

What is a control structure?

A

A statement ( for, while)+ statements whose execution is controlled

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

Is it possible for a control structure to have multiple entries?

A

Yes but only with goto statements

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

Does goto statements increase or decrease readability?

A

Decrease

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

What is a 2 way selection statement?

A

If then(1st way) else (2nd way)

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

What is a multiple selector statement

A

Switch/case statements, elif. Can go to more than 2 places

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

What is a important design issue with how nested selectors work?

A

How to know which else is for which if

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

What is the control expression?

A

The conditional statement which is usually boolean

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

How does Java “Assign” a else to an if? (no braces)

A

It assigns the else to the nearest if.

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

What is a common way to “Assign” a else to a if?

A

Forced semantics ( {} )

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

If the if expression returns a value there must be a ….?

A

Else clause

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

What can go inside of a selectable segment in a switch case statement?

A

Statement sequences or compound statements (blocks)

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

What components does a counting iterative statement have?

A

A loop variable + initial value, + terminal value + stepsize

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

Design issues for counter-controlled loops?

A

Should loop variable be able to change inside of the loop. What is the scope of the loop variable. What is the loop variable value after the loop

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

Basic structure for Counter Controlled loops example for C-based languages.

A

For( expr1; expr2; expr3) statement

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

Can the 1st expression in a counter controlled loop in c++ declare a variable for use?

A

Yes. for(int i = 0; i<10; i++)statement

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

What makes Python for loops “special”?

A

It has a else clause

17
Q

What is the use of the else clause in pythons for loop?

A

It executes after the loop has completed

18
Q

What is a logically controlled loop?

A

A Repetition caused by a boolean expression

19
Q

Can every counter controlled loop be written as a logically-controlled loop?

20
Q

What is pretest vs posttest

A

Pretest = check condition then execute block
posttest = execute block and then check condition

21
Q

What are some user loop control mechanisms

A

Breaks or continues

22
Q

What does the “continue” control statement do?

A

Skips the rest of the current iteration

23
Q

What s iteration based on data structures?

A

Iteration is controlled by the number of elements in a data structure

24
Q

What is unconditional branching?

A

Transfer control to a specific place in program ( uses goto)

25
What are guarded commands?
If order of evaluation is not important, program shouldnt specify an order
26
How does selection with guarded command look like?
if booleanExp -> stat1 [] booleanExp2 -> stat2 .... [] booleanExpn->statn fi do looks the same but with do and od
27
Why is guarded commands needed?
Non-deterministic Aborting behaviour No specific order