Unit 5 : Algorithm - Repetition Structure Flashcards
1
Q
What is repetition structure?
A
- Specifies a block of one or more statements that are repeatedly executed until a condition is satisfied
2
Q
What are the types of repetition structure? ( 2 )
A
- Counter Based
- Sentinel Based
3
Q
List out the 2 important parts of a loop
A
- An expression that is tested for a true / false
- A statement or block that is repeated if the expression is true
4
Q
What is a counter based repetition structure? ( 1 )
A
- It can be used to control number of execution of the loop
5
Q
What do we need to do when setting up a counter? ( 2 )
A
- Initialized before entering loop ( i )
- It will increase or decrease each time a loop repeats
6
Q
What is sentinel repetition structure mostly based on ?
A
- 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
7
Q
What are the pseudocode for counter based pseudocode?
A
- LOOP counter FROM InitVal TO EndVal STEP increment_value
statement
NEXT counter
ENDLOOP
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
9
Q
What shapes can flowchart represents repetition structure?
A
- Hexagon
10
Q
What are the value that the hexagon repetition structure required in flowchart? ( 4 )
A
- Variable Name
- Initial Value
- End Value
- Increment / Decrement