Problem Decomposition Flashcards
What is decomposition?
Breaking down a problem into smaller parts or sub-problems
How can parts of a problem be solved?
They can be solved by using discrete algorithms (ones which follow a simple input-process-output pattern)
What is an algorithm?
It is a set of instructions intended to solve a problem
What are features of a good algorithm?
Clear steps to produce the correct output for any steps of valid inputs
Should allow for invalid inputs
Must always terminate at some point
Should execute efficiently
Should be designed in a way that other people can understand it
What is a subroutine?
It is a block of code that is usually give a name
How are subroutines executed?
Subroutine are called and are executed form beginning to end. Then control is passed back to the line containing the subroutine call
What are parameters?
They are things which are passed into subroutines.
What is an argument?
It is the values specified for a parameter when a subroutine is called
What is the difference between subroutines and functions?
Functions are subroutines that return a value. Procedures are subroutines which don’t return a value
How are functions written in pseudocode?
Function doubleIt(number) Return 2 * number End function
What are used for structure diagrams/ hierarchy charts?
They are used to identify major tasks and break them down into subtasks
How are structure diagrams different from flow charts?
They don’t show data flow, instead they show chunks of functionality and code structure
How are hierarchy charts structured?
At the top is the whole program/project
Then is the tasks/abilities of the program (often these are source code files)
The bottom level is the functions/procedures (mostly following the input process output pattern)
What is a trace table?
It is used to check an algorithm at the design stage to see if it is going to work as planned
What are the columns and rows representing in a trace table?
Each column represents a variable or the output of the program
Each row represents each point in time or different stages of the algorithm that has been written