2.1 - Elements of computational thinking Flashcards
What is computational thinking?
Ability to think logically about a problem + apply techniques for solving it.
Related to skill of designing algorithms -> turned into computer program
What is abstraction?
- Removing unnecessary details from the problem + focusing on the main part or one part at a specific time.
- Seperating the logical & physical aspects of a problem.
- e.g. Physical = Driver for a car, Logical = Mechanic for a car.
What can you create with abstraction?
- Devising a model that represents reality & removing details that don’t contibute to the central characteristics of the problem. E.g. London underground map.
How do you solve a problem using abstraction?
- Can build a model of a real world object/Phenomenun may be used to help solve a particular problem.
- Decide what details are relevent to the problem + discard everything else.
- Algorithms + data structures can be designed to solve the problem.
- Algorithm is then implemented in program code + executed.
- e.g. Financial model - calculates likely profit of coffee shop from availible data.
What is an abstract model?
A computer program shown by a simple diagram. Details are added until it is transformed into a computer program.
What are the 3 parts of a abstract model?
- Input = information relevent to the problem. e.g. could be passed as parameter to a subroutine.
- COMPUTATIONAL PROBELM.
- Output = Solution to the problem. e.g. could be passed back from a subroutine.
What are the 2 challenges to creating a solution?
- Algorithm must be CORRECT - must work for all possible inputs.
- Algorithm must be EFFICIENT - Often problems involve lots of data so must find most efficient algorithm.
What should you do with inputs & outputs?
- Document / Identify them so that there is no ambiguity in what must be supplied to the sub-procedure, and what is returned.
What is Decomposition?
Breaking a problem into a number of sub problems, so each sub problem accomplished an identifiable task.
Sub programs can be further divided.
What are the 4 features of structured programming?
- It aims to improve the clarity and quality of a program.
- Modularization for program structure + organisation
- Structured code for the individual models; code uses basic constructs of sequence, selection & iteration.
- Recursion
What is modularization?
(In the context of structured programming)
Breaking the program into subroutines.
What is the Top-down model technique?
- Program divided into sub-procedures or modules which are called from the main program.
- Sub-procedurs can be broken down further into smaller sub tasks (Smallest part can perform a single function).
- Represented in a heirachy chart to show overall program structure.
How is a heirachy chart executed?
Left to right until the lowest component. (Will go down the tree back up and then continue along)
What are the 8 benefits of Modularization?
- large programs broken down into subtasks/subroutines = easier to program + manage.
- Each subroutine can be tested individually.
- Modules become reusable.
- Frequently used modules can be saved in a library & used by other programs.
- Several programmers can simultaneously work on different modules, shortening developmentive time.
- easier to find errors in small modules so program = more reliable + less errors.
- Programs take less time to test + debug.
- Programs are easier to maintain.
What are the 2 features of an easy to maintain program?
- Well organised, easy to find and self contained modules.
- New features added by adding new modules.
What are the 5 features of good programming practice?
- Meaningful identifiers.
- Define + document inputs/outputs/preconditions for each sub-procedure.
- Lots of meaningful comments within the program.
- At bottom level, each sub procedure should perform a single task.
- Keep each sub-procedure self contained by passing parameters + local variables.
What should you do once you have identified the components of the program?
Plan the overall method of the solution; involves writing procedures/functions + passing parameters.
e.g. car dealer wants program to help potential customer select options for a new car.
What are the 3 advantages of preconditions?
- Makes program components reusable.
- Cuts out unnecessary checks.
- Makes programs easier to debug.
What are the 5 typical standards for reusable models?
- Inputs + Outputs + preconditions should be documented in standard format. (explaining what the module does who it was written by, date is was)
- Variable identifiers should conform to standard convention.
- All variables should be local to the module.
- Explanations of certain sections of code should be included when necessary.
- No module should exceed one page of code.
Why are the 3 reasons for a program module to be reusable?
- Easier to use for other programmers.
- Can be added to a library + imported whenever needed.
- In a large project - saves time in writing + testing functions which have already been written, debugged and tested.