Thinking Logically Flashcards
What makes a good algorithm?
Clear steps that produce the correct output for any set of valid inputs.
Should allow for invalid inputs.
Must always terminate at some point.
Should execute efficiently, in as few steps as possible.
Designed so others can understand and modify it.
What are 3 tools for designing algorithms?
Hierarchy charts: useful for identifying the major task and breaking down into subtasks
Flowcharts: useful for getting down initial ideas for individual subroutines
Pseudocode: will translate easily into program code
What are decision points (diamonds in flowcharts)?
The parts of an algorithm that can change the flow/outcome of a solution
What are examples of decision points?
IF and CASE statements.
<, >, ==, AND, OR, NOT
What is hand-tracing algorithms useful for?
Figuring out how an algorithm works and why it isn’t working properly
What is a trace table used for?
To write down the contents of each variable as it changes during execution
What is program flow?
The order in which individual statements, instructions or function calls of an imperative program are executed or evaluated
When identifying where a decision point is, what else do you need to explain?
Why it is there