2.1 Elements of Computational Thinking Flashcards
What is abstraction?
Making a problem easier to solve by removing unnecessary detail and leaving only fundamental components to provide a computational version of reality
Involves devising a model that REPRESENTS reality
What are computers models?
Store data about a topic and use these to model/predict behaviours
What are the uses of computer models and simulations?
Predictions of global warming, effects of climate change
Likely scale and effects of population increases
Number of doctors and teachers required in 10 years time
Prediction of likely consequences of an earthquake
Financial modelling to predict future profits/losses
Likely spread of disease such as Covid
Saving in field of a new car/aircraft design
What is thinking ahead?
Considering all possible inputs and outputs to a system
What format will the inputs be in and where do they come from (from user input or sensors)
What format will be the outputs be in (documents, sound)
What processes will need to take place on the data in the system
What is modular programming?
Taking a problem and breaking it down into smaller problems, each of which can be easier to solve
Splitting code into different subroutines and/or different files
What are the advantages of modular programming?
Can take different problems and distribute them across a team of developers
Each module can be reused, reducing memory footprint, speeding up development time and making coding more consistent
Each module should’ve been thoroughly tested
Saves development time as all developing simultaneously
Project can be easier to manage as you aren’t relying on one piece of code to be finished to do another
What is procedural decomposition?
Breaking a problem into a number of sub-problems so that each sub-problem accomplishes an identifiable task
Sub-problems may then be further subdivided
What is structured programming?
Aims to improve clarity and quality of code
Modularisation - for program structure and organisation, structured code for individual modules (code using sequence, selection and iteration), recursion
Uses top-down design techniques
Program divided into modules which are called from main problem
Any sub-procedures may be further broken down into smaller sub-tasks, with smallest performing single function
Hierarchy chart - used to show overall program structure
What is a hierarchy chart?
Each logical process broken down into smaller components until it can’t be broken down any further
Execution tasks place from left to right, always at the lowest level component
Selection and iteration not shown
What is thinking logically?
Identify the points where a decision has to be taken
Determine the logical conditions that affect the outcome of a decision
Determine how decisions affect flow through a program
What are the features of a good algorithm?
Has clear and precisely stated steps
Produces correct output for any set of valid inputs
Validates against invalid inputs
Terminates at some point
Should be efficient, execute in as few steps as possible
Should be designed in such a way that other people will be able to understand it and modify it if necessary
What are the different methods for designing algorithms?
Hierarchy charts
Flowcharts
Pseudocode
What are hierarchy charts useful for?
Identifying major task and breaking these down into subtasks
What are flowcharts useful for?
Getting down initial ideas for individual subroutines
What is pseudocode useful for?
Will translate easily into program code
What is hand tracing useful for?
Figuring out how an algorithm works
Finding out why an algorithm is not working properly
How are trace tables used?
To write down contents of each variable as it changes during execution
If program contains a loop, helpful technique is to put loop condition as first column in trace table, even if other variables have been defined before
ONLY NEED TO ENTER THE VALUES THAT CHANGE INTO A TRACE TABLE
Why is caching used?
Impossible to store all data locally at once, ready to processed
What is caching?
Cache blocks of data that need to be processed - loaded from server to the client machine - so that data could then be processed at a quicker speed
Processed data can then be uploaded back to database on web server
When data cached, temporary copy stored so it can be accessed again faster
What are the benefits of caching?
By using blocks of data rather than constant access to and from database, reduces load on database server
If data in use is cached to client machine as block, if problem with server or connection to server then data can still be processed, reducing reliance on good connection to the server
What are the drawbacks of caching?
Decrease performance if database held away from client machine, as all data is processed locally
Problems synchronising data (if data cached onto machine and different copy held on server, could be issue with keeping data up to data and consistent if more than one machine able to access data at once)
Increase maintenance costs as database need maintaining (checking consistency of data)
If problem with server (crashes) then if data already on client’s machine then won’t be able to reuploaded
What is concurrent processing?
Where one process doesn’t need to finish before next process start
Multiple processors execute instructions simultaneously
What is parallel processing?
Using multiple processors
Each processor works simultaneously and independently
CONSIDERED CONCURRENT
How does concurrent processing work?
Tasks broken down into subtasks that can be assigned to separate PROCESSORS/run on different THREADS and therefore run independently
A task can begin without waiting for another task to FINISH FIRST so tasks can OVERLAP
Each thread starts and ends at a different time
What are the advantages of concurrent processing?
Less hardware bottlenecks
More efficient processing of interrelated tasks
More efficient use of processor time
Parallelism
Througput
Processor maximised
Reactive programming
Why does concurrent processing cause less hardware bottlenecks?
Programs should be more responsive because idle time between hardware interactions filled
Less time wasted waiting for an input or user interaction as other tasks can be completed
Why does concurrent processing allow more efficient processing of interrelated tasks?
Processor doesn’t need to wait for other threads to be able to complete executing before starting processing on another task
Multiple threads and processes can be executed simultaneously on different cores
Why does concurrent processing allow more efficient use of processor time?
Maximises use of each processor and reduces amount of idle time
Maximises throughput of processor meaning amount of tasks that can be completed within given amount of time
How does concurrent processing allow parallelism?
Complex programs can make better use of multiple resources in multi-core processor systems
Why does concurrent processing maximise throughput?
Allowing multiple tasks to run concurrently will increase program throughput (e.g. number of tasks completed in a period of time)
Why does concurrent processing maximise processors?
Processor is not waiting for user input etc but can be competing actions from other threads whilst otherwise would be paused
Why does concurrent processing allow reactive programming?
User is able to interact with applications while other tasks are running
What are the disadvantages of concurrent processing?
Concurrent can be slower than serial execution
Overheads in concurrent processing
Deadlock can occur in extreme circumstances
Memory intensive
Footprint
Resource consumption
Coding
Why can concurrent processing be slower than serial execution?
When large numbers of users or tasks are involved as processes cannot be completed at once and will continually be paused whilst other tasks and threads are give processor time
Why are there overheads in concurrent processing?
Running tasks on multiple processors will incur overheads as data needs to be moved between processors, threads and processes need to be paused and tasks need to be split to run on different processors
Why can deadlock occur in extreme circumstances in concurrent processing?
When two processes are being executed at the same time and each locks a resource that is needed by the other resource
OS would need to implement methods to deal with this
Wouldn’t happen with serial execution
Why is concurrent processing more memory intensive?
Running multiple threads will be more intensive on the computer’s memory
Why does concurrent processing have a greater footprint?
Program will have a larger memory footprint due to complex nature of coding
Why does concurrent processing increase resource consumption?
Threads can be expensive
Overhead associated with scheduling, switching threads and synchronising them
How does concurrent processing increase the complexity of code?
Programming multiple threads can be challenging and complex