Unit 2.1 - Computational Thinking

?

Unit 2.1.2 - Thinking Ahead

Input - Information relevant to the computational problem (e.g. for an ATM and input would be entering a balance to widthdraw)

Output - Solution to a problem that could be passed back from a subroutine (e.g. if balance entered to widthdraw, give the user that specified amount of money)

Two major challenges when producing a solution to a compuational problem is making the algorithm correct (works for all inputs) and efficient (able to hand a lot of data at once)

Preconditions - Requirements that must be met befoe a program can be executed or else an error will return or program will fail to execute

  • Preconditions in the program (functions, procedures, if statements) need to be incuded in the documentation
  • Having preconditions means subroutines can safely expect the arguments passed to meet certain critera and if a condition is not met then the program can take a shorcut and ignore all the other code
1 of 4

Unit 2.1.2 - Reusing components & Caching

Commonly used functions are packaged into libraries for reuse in many different programs, using libraries is good programming as:

  • Functions are well-tested, bug fixed which saves time as programmers know that the function will work for specified preconditions which come packaged with them
  • Programmers can also create their own libraries that they can use in multiple projects saving them a lot of time

Caching - Stores commonly accessed information that can be retrieved very quickly

  • Computers use a method of caching called prefetching where they computer thinks ahead/anticipates the next piece of data and retrieves it so that it can be quickly ran, however, if the wrong data is prefetched it can slow down the computer as processor time has to be wasted dumping the data and retrieving the correct data
  • Computers only have a very small amount of cache memory stored close to the CPU as it is very expensive meaning that only snippets of a program can be placed in cache
2 of 4

Unit 2.1.4 - Thinking Logically

A decision in a program is a result that is reached after some consideration, this can be chosing a piece of software to use for a project or how you are going to collect user data

To simplify this process, the number of inputs should be limited by getting rid of choices that make sence e.g. Choosing a language to develop a program in and only knowing Python and C++ you wouldn't choose HTML as it it not feasible

To aid with this a flow chart can be used using the decision symbol (diamond) for which two results are possible, True and False

By making the decsion process as simple as possible it means that the best outcome possible, this can be helped by asking questions such as: What is most effective/convenient and is the option reasonable for the problem

Logical thinking allows you to prepare and plan for different scenarios by providing a foresight of the decisions made through the whole program and their possible outputs

3 of 4

Unit 2.1.5 - Thinking Concurrently

Concurrent Processing - Process of completing more than one task at a time, done by giving processes a slice of processor time to complete their task (round robin, shortest time first, etc) this gives the illusion that each task is being completed simultaneously

An example of this is recording the colour and numberplate of passing cars, A concurrent approach is recording the number plate and then the colour before moving onto the next car (Most effective and efficient way)

Parallel Processing - Uses multiple processors (or cores) to complete more than one task simultaneously, can only happen when using multiple cores although software has to be written to take advantage of this

  • A processor with 4 cores will not run 4 times faster than a processor with 1 core unless the software is specifically written to take advantage of this process

One disadvantage of concurrent processing is that if a process relies on an output from another function it cannot be used

4 of 4

Comments

No comments have yet been made

Similar Computing resources:

See all Computing resources »See all Computational Thinking resources »