Unit 5 : Algorithm - Repetition Structure Flashcards

1
Q

What is repetition structure?

A
  1. Specifies a block of one or more statements that are repeatedly executed until a condition is satisfied
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the types of repetition structure? ( 2 )

A
  1. Counter Based
  2. Sentinel Based
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

List out the 2 important parts of a loop

A
  1. An expression that is tested for a true / false
  2. A statement or block that is repeated if the expression is true
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is a counter based repetition structure? ( 1 )

A
  1. It can be used to control number of execution of the loop
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What do we need to do when setting up a counter? ( 2 )

A
  1. Initialized before entering loop ( i )
  2. It will increase or decrease each time a loop repeats
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is sentinel repetition structure mostly based on ?

A
  1. User input
  • User input determintes loop repetition
    Their input is prompt before loop so that then the input is used to control number of repetitions
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are the pseudocode for counter based pseudocode?

A
  1. LOOP counter FROM InitVal TO EndVal STEP increment_value
    statement
    NEXT counter
    ENDLOOP
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the pseudocode for sentinel based repetition structure ?

A

DOWHILE (condition is true for value)
statement_block
Prompt user for value
Read value
ENDDO

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

What shapes can flowchart represents repetition structure?

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

What are the value that the hexagon repetition structure required in flowchart? ( 4 )

A
  1. Variable Name
  2. Initial Value
  3. End Value
  4. Increment / Decrement
How well did you know this?
1
Not at all
2
3
4
5
Perfectly