Algorithms Sheet 2 - Only Programmerz (Best Spot for
Download
Report
Transcript Algorithms Sheet 2 - Only Programmerz (Best Spot for
Algorithms Sheet 2
Identifying Control Structures
1. Match the terms sequence, binary
selection, multiway selection and
iteration to the descriptions that follow:
(a) a decision taken in an algorithm which can
go either of two ways
binary selection
(b) decision taken in an algorithm which allows
morethan
thantwo
two choices
more
multiway selection
1. Match the terms sequence, binary
selection, multiway selection and
iteration to the descriptions that follow:
decision taken in the processing done by an ATM
(c) a decision
to either withdraw, deposit or check account balance,
more than two
depending on the key pressed
multiway selection
repeats the same
(d) a loop in a process which repeats
instructions a number of times
iteration
1. Match the terms sequence, binary
selection, multiway selection and
iteration to the descriptions that follow:
(e) a part of a program where we always
always add 1 to
a counter and then print
sequence
(f) a portion of a program that is done over
and
over and
over
again, and only stops when the count
over again
reaches zero
iteration
2. Identify two of the control structures
used in each of the following algorithms
(a)
Count = 0
REPEAT
DoTheLoop
Add 1 to Count
UNTIL Count = 5
sequence
iteration/repetition
sequence
2. Identify two of the control structures
used in each of the following algorithms
(b)
WHILE Count <= 5
Add 1 to Count
DoTheLoop
END WHILE
iteration/repetition
sequence
2. Identify two of the control structures
used in each of the following algorithms
(c)
Get NextVideo
IF category = ‘X’
THEN print ‘You cannot watch this!’
ELSE DoBorrowProcess
Print details
END IF
sequence
selection (binary)
2. Identify two of the control structures
used in each of the following algorithms
(d)
REPEAT
Enter Number
IF Number > highest
THEN set highest to Number
END IF
UNTIL no more Numbers
iteration/repetition
sequence
selection
2. Identify two of the control structures
used in each of the following algorithms
(e)
WHILE more input
Select input
CASE 1
iteration/repetition
selection (multiway)
DoWithdrawals
CASE 2
DoDeposits
CASE 3
DoAccountBalance
CASE other
DoErrorProcess
END select
Get input
END WHILE
sequence
3.
Identify the
control structure
other than
sequence
used in the
following
algorithms:
3.
Identify the
control structure
other than
sequence
used in the
following
algorithms:
3.
Identify the
control structure
other than
sequence
used in the
following
algorithms:
3.
Identify the
control structure
other than
sequence
used in the
following
algorithms:
Remember
You need to know how to apply
this information, so see me for
further help if you think it is
necessary for you.