Algorithms and Programming Constructs Flashcards
What is an algorithm
A process/set of rules to be followed in order to produce a solution
Characteristics of an algorithm
- Not language dependent (can be converted into any language)
- unambiguous
- will take an input, process it and produce an output
How can algorithms be represented
using flowcharts, pseudocode or computer programs
start/stop procedure flowcharts
rectangle with curved corners
decision box flowcharts
diamond
input/output flowcharts
parallelogram
operation flowcharts
rectangle
connector flowcharts
circle
store/subroutine call flowcharts
rectangle with a line on each edge
flow of control flowcharts
arrow - arrowhead indicated direction of flow
declare & end subroutine pseudocode
Declare ThisIsASubroutine
End Subroutine
Call a subroutine pseudocode
call SubroutineNeeded
Declare and use arrays pseudocode
myarray[99]
Literal outputs pseudocode
output “Please enter a number”
Variable names pseudocode
myvariable
Define variable & data type pseudocode
myvariable is integer
Data types
integer, character, string, boolean, real
Assignment (of values to variables) pseudocode
set myvariable = 0
selection pseudocode
if ___ then
blah blah
end if
annotation pseudocode
{some annotation goes here}
For loop pseudocode
for i = … to …
blah blah
next i
repeat until loop pseudocode
repeat
blah blah
until …
do loop pseudocode
do
blah
loop
do while loop pseudocode
do
blah
while …
while repeat loop pseudocode
while
blah
repeat
Logical operators pseudocode
AND OR NOT XOR
TRUE FALSE
Subroutine definition
section of code in a program that carries out a specific task and can be done more than once