2.1 computational thinking Flashcards
deifine abstraction
abstraction is the act of removing unecessary details
why is abstraction implemented
because it can provide the same quality product while reducing the computational resources required
focus on the purpose of the program
reduce complexity fo the design
reduce programming coplexity
reduce memory requirements
define preconditions
Things to consider before creating the solution i.e
budget, time frame, current solution, current hardware, skill set etc
what are the three main aspects of thinking ahead
specifying inputs
specifying outputs
preconditions
what are the pros of defining preconditions
makes program components reusable
cutting out unecessary checks
makes the program easier to maintain
enhances modularity
reduces errors
what are the main programming standards
function shouldnt be longer than a page of code
variable identifiers must stick to a convention
each function must have a single entry point
variable must not be set up ouside the scope of the function (local variables)
how do operating systems utalise ‘Thinking ahead’
by caching frequently accessed data
this can be done with prefetching where an algorithm predicts the next data to be fetched and places it in cache before it is fetchied into the CPU
pros of caching
faster access
less bandwidth used
cons of caching and prefetching
disk thrashing may occur if used to often
there is a chance that the algorithm is wrong and the data prefetched isnt needed next.
define decomposition
breaking up the problem into small more managable sub-problems
what are the benefits of modularisation
large problems broken down easier to solve
subroutine can be tested individually
modules can be resued in several programs
frequently used modules can saved as libraries
programmers can work concurrently
programs have fewer errors
easier to debug
easier to maintain
what does a good algorithm include
clear set of steps to prodice the correct output
is efficient and completed in as few steps as possible
how is concurrent processing done
multiple cores
tasks broken down into subtasks
pros of concurrent processing
solution found faster
increase program throughput
(rate a system can complete a task)
cons of concurrent processing
more memory
more difficult to program