Karteikarten
Cp1401 weeks 3-4
Karten in diesem Stapel (14)
- 1What is a function?A function is a construct you can use to combine local variables and statements to perform a single task
Self-contained segment of code that accomplishes a specific task.
Can be called multiple times.
Reduces repetitive lines of code - 2What is the function scope?Each function only knows about its own data. (local variables)
- 33 Categories of functionsInput, Output, processing
- 4What is function recursion? indirect recursion?recursion - a function should not call itself
indirect recursion - function calling back to a function that called it. - 5What is a decision?In algorithm design (and programming) all decision are done with comparisons
All the standard mathematical comparisons are available to us:
Equal (=)
Less than (<)
Greater than (>) - 6Boolean?“Boolean” value (variable type)
Is either “True” or “False” (“Yes” or “No”, 0 or 1)
ALL decisions MUST be “boolean”
The result of a decision MUST be “True” or “False”
“Yes” or “No” - 73 types of decisionsSingle path decision
Two possible paths
Many paths - 8What is used to plan our decisions?Condition/Action tables
- 9What are iterationsthe repetition of a process
- 103 parts of a loopLoop variable - what value are we checking
loop body - what happens in the loop
exit condition - when do we stop - 11What is a sentinel value?is a special value in the context of an algorithm which uses its presence as a condition of termination.
- 12Boolean AlgebraAllows us to combine boolean values to produce new boolean values
- 13Boolean operatorsAND, OR, NOT
- 14What is an array?An “array’ is a whole list (or collection) of data
Accessed by a single variable name