unit 1 - fundamentals of algorithms Flashcards
what is an algorithm?
a set of instructions for solving a problem or completing a task
what is abstraction?
removing unnecessary detail from a problem so that you can focus on the essentials
what is decomposition
breaking down a large problem into smaller sub-tasks, which can then be further broken down until each small task is manage
arithmetic operators
+ add
- subtract
/ divide
* multiply
^ exponent
MOD division with a remainder
DIV integer division
what is a variable?
is a location in memory where you can temporarily store text or numbers
what are two tools to plan and write algorithms?
- pseudocode
- flowcharts
what are the three programming constructs?
- sequence
- selection
- iteration
data types
integer - a whole number
real - a number with a decimal point
boolean - can only be TRUE or FALSE
character - a single alphabetic or numeric character
- string - one or more characters enclosed in quote marks
boolean operators
> greater than
< less than
= greater than or equal to
<= less than or equal to
= equal (== in python)
/= not equal (!= in python)
what is sequence?
the statements are executed in the order that they are written
what is selection?
- an IF statement in a selection statement
- the next statement to be executed depends on whether the condition tested is TRUE or FALSE
what is pseudocode?
- a structured english for describing algorithms
- allows the designer to focus on the logic on the algorithm without being distracted by the syntax
how to assign a value to a variable in pseudocode?
total <- 0
cost <- adult * child
counter <- counter + 1
how to write an input/output in pseudocode?
firstname <- USERINPUT
OUTPUT (“enter a value”)
what does iteration mean?
- repetition of a certain block of code