Elements Of Computational Thinking Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

Abstraction

A

Abstraction is one of the most important principles in Computer Science and is a critical part of computational thinking. It is the process of ​removing excessive details​ to arrive at a representation of a problem that consists of only the​ key features​. Abstraction often involves analysing ​what is relevant​ to a given scenario and simplifying a problem based on this information. This is called ​representational abstraction​.

Another form of abstraction involves​ grouping together similarities​ within a problem to identify what kind of problem​ it is. This is called ​abstraction by generalisation​ and allows certain problems to be​ categorised as being of a particular type​. Thus a ​common solution can be used to solve these problems.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Data abstraction

A

Data abstraction​ is a subcategory of abstraction in which details about how data is being stored are hidden​. As a result, programmers can make use of ​abstract data structures​ such as stacks and queues without concerning themselves with how these structures are implemented.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Uses for Abstraction

A

Programmers can also perform functions such as pushing and popping items to and from a stack ​without having any knowledge about the code used to implement this functionality​. This is called procedural abstraction and is also used in decomposition. It models what a subroutine does without considering how this is done. Once a procedure has been coded, it can be reused as a black-box.

Very large, complex problems make use of​ multiple levels of abstraction​, where each level performs a different role. The highest levels of abstraction are ​closest to the user​ and are usually responsible for​ providing an interface​ for the user to interact with hardware whereas the lowest levels of abstraction are responsible for actually performing these tasks through the execution of machine code.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

The need for abstraction

A

At its core, abstraction allows ​non-experts to make use of a range of systems or models​ by hiding information​ that is ​too complex or irrelevant​ to the system’s purpose.

Abstraction enables for ​more efficient design​ during software development as programmers can focus on elements that need to be built into the software rather than worrying about unnecessary details. This then ​reduces the time needed to be spent on the project​. Removing wasteful details early on also​ prevents the program from getting unnecessarily large​.

Layers of abstraction are used within​ networking​ and ​programming languages​. Programming languages can be separated out into a spectrum of​ high and low-level languages​. Low-level languages such as assembly code and machine code ​directly interact with computer systems​ but are more ​difficult to write​. Programming using machine code requires having an understanding of ​the functions specific binary codes perform​ and although assembly code is easier to memorise, it still requires programmers to know the mnemonics associated with the instruction set​ specific to the processor. High-level languages provide an abstraction for the machine code that is in fact executed when a program is run. This makes the process of developing programs easier, as ​syntax in high-level languages parallels natural language​ and is​ considerably easier to learn​ and use compared to low-level languages. This has also made coding ​accessible to non-specialists​.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

The need for abstraction (TCP/IP)

A

The ​TCP/IP model​ is an abstraction for how networks function, separated into​ four layers of abstraction: application, transport, internet and link​. Each layer deals with a ​different part of the communication process​, and separating these stages out makes them simpler to understand. Each layer does not need to know how other layers work. Outgoing communication is visualised as going down these layers, while incoming information can be imagined as going up these layers. However, it is also important to​ ensure compatibility
between these layers ​so ​standards ​must be agreed in advance. The TCP/IP model uses a ​set of protocols ​which means that each layer can be dealt with individually, with details about other layers being hidden.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

The difference between abstraction and reality

A

Abstraction is a ​simplified representation of reality​. Real-world entities may be represented using ​computational structures​ such as tables and databases. Real-world values are often stored as ​variables​.

Object-oriented programming​ makes use of ​objects​, which are also an ​abstraction for real-world entities​. In object-oriented programming, abstraction considers the functionality, interface and properties of entities​. Attributes are an abstraction for the characteristics of an object while methods are an abstraction for the actions a real-world object is able to perform.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

When devising an abstract model given a scenario, you must consider:

A
  • What is the problem that needs to be solved by the model?
    Can the problem be solved computationally? What are the key features of the problem?
  • How will the model be used?
    What sort of format does the model need to be displayed in? Consider factors such as convenience, affordability and ease of access​.
  • Who will the model be used by?
    How many people will be using the model? What level of expertise do they have in the subject/ discipline associated with the problem?
  • Which parts of the problem are relevant based on the target audience and the purpose of the model?
    Remove sections that are not relevant to the problem that needs solving. Remove details that will confuse the audience.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Identify the inputs and outputs for a given situation

A

Designing a solution entails thinking ahead about the ​different components of a problem and how they will be ​handled in the best way​ possible. Thinking ahead allows developers to consider problems or difficulties that may arise when the software is used. Taking these factors into account at an early stage, developers can design strategies to make programs easy and intuitive to use​.

At their core, all computational problems consist of inputs which are processed to produce an output. ​Inputs ​include any ​data that is required to solve the problem​, entered into the system by the user. Often, the ​order ​in which data is input and the ​method ​of input must also be taken into consideration. ​Outputs ​are the ​results that are passed back once the inputs have been processed and the problem solved. Designers must decide on a​ suitable data type, structure and method​ to use in order to present the solution, given the scenario.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Preconditions

A

Preconditions ​are​ requirements which must be met before a program can be executed​. If the preconditions are not met, the program will fail to execute or return an invalid answer. Specifying preconditions means that a subroutine can ​safely expect the arguments passed to it to meet certain criteria​, as defined by the preconditions. Preconditions can be ​tested for within the code​ but are more often​ included in the documentation​ accompanying a particular subroutine, library or program.

Preconditions can also be included within the documentation, in which case it is the user’s responsibility to ensure inputs meet the requirements specified by these preconditions. A common example of this is the​ factorial f​unction, which can only be called upon positive numbers. Rather than checking that the arguments passed to the function must be non-negative​, this is​ specified within the documentation accompanying this function​. Including preconditions within the documentation ​reduces the length and complexity of the program​ as well as ​saving time needed to debug and maintain​ a longer program.

The purpose of preconditions is to ensure that the necessary checks are carried out before the execution of a subroutine, either by the user or as part of the subroutine. By explicitly ensuring these conditions are met, subroutines are made ​more reusable​.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Caching

A

Caching is the process of ​storing instructions or values in cache memory​ after they have been used, as they​ may be used again​. This ​saves time​ which would have been needed to store and retrieve the instructions from secondary storage again. Caching is very common in the ​storage of web pages​. The web pages that a user frequently accesses are cached, so the next time one of these pages is accessed, content can be​ loaded without any delay​. This also means images and text do not have to be downloaded again multiple times, freeing up bandwidth​ for other tasks on a network.

A more advanced variation of caching and thinking ahead is ​prefetching​, in which algorithms predict which instructions are likely to soon be fetched​. The instructions and data which are likely to be used are then ​loaded and stored in cache before they are fetched​. By thinking ahead, therefore, ​less time is spent waiting ​for instructions to be loaded into RAM from the hard disk.

Clearly, one of the biggest limitations to this is the ​accuracy of the algorithms used​ in prefetching, as they can ​only provide an informed prediction​ as to the instructions which are likely to be used and there is no guarantee that this will be right. Similarly, the effectiveness of caching depends on how well a caching algorithm is able to manage the cache. Larger caches still take a long time to search and so ​cache size limits how much data can be stored​. In general, this form of thinking ahead can be ​difficult to implement​ but can significantly improve performance if implemented effectively.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Reusable Program Components

A

Commonly used functions​ are often ​packaged into libraries for reuse​. Teams working on large projects that are likely to make use of certain components in multiple places might also choose to put together a library so these components can be reused. Reusable components include​ implementations of abstract data structures​ such as queues and stacks as well as ​classes and ​subroutines​. When designing a piece of software, the problem is ​decomposed​: it is ​broken down into smaller, simpler tasks​. This allows developers to think ahead about how each task can be solved, and identify where ​program components developed in the past​, or​ externally-sourced program components​, can be ​reused ​to simplify the development process.

Reusable components are ​more reliable​ than newly-coded components, as they have already been tested​ and any bugs dealt with. This ​saves time, money and resources​. Subroutines can then simply be reused with different arguments to produce a variety of outputs. Producing well-tested, reusable components means that they can also be ​reused in future projects​,​ saving development costs​. However, it may not always be possible to integrate existing components developed by third parties due to ​compatibility issues​ with the rest of the software. This may mean these components need to be modified to work with existing software, which can sometimes be more costly and time-consuming than developing them in-house.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Identify the components of a problem

A

In computer science, ​thinking procedurally​ makes the task of writing a program a lot simpler by breaking a problem down into smaller parts which are ​easier to understand​ and consequently,​ easier to design​.

The first stage of thinking procedurally in software development involves taking the problem defined by the user and​ ​breaking it down into its component parts, in a process called ​problem decomposition​. In this process, a​ large, complex problem is continually broken down into smaller subproblems ​which can be solved more easily. By separating the problem into sections, it becomes more​ feasible to manage​ and can be ​divided between a group of people​ according to the skill sets of different individuals.

This process requires software developers to consider a problem in terms of the underlying subproblems that need to be solved​ to achieve the desired result

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Problems are commonly decomposed using ​top-down design​:

A

This is also known as ​stepwise refinement​, and is the preferred method used to approach very ​large problems​, as it breaks problems down into ​levels​. Higher levels provide an overview of a problem, while lower levels specify in detail the components of this problem.

The aim of using top-down design is to keep splitting problems into subproblems until each subproblem can be represented as a ​single task​ and ideally a​ self-contained module or subroutine​. Each task can then be solved and developed as a subroutine by a different person. Once programmed, subroutines can also be ​tested separately​, before being brought together and finally integrated.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Identify the components of a solution

A

This is the stage in which the details about how each component is implemented are considered. You will be able to see below how separating out these components has made it easier to identify a feasible and programmable solution.

In the same way that we broke down the problem, we must also ​build up to its solution​. In order to identify the components of the solution, each programmer must evaluate the component of the problem allocated to them and assess how it can best be solved. Going back to our previous example involving the book reservation system, we need to consider the ​lowest-level components​.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Order of steps needed to solve a problem

A

When constructing the final solution based on the solutions to the problem components, thinking about the ​order in which operations are performed​ becomes important. Some programs might require certain inputs to be entered by the user before the processing can be carried out. These inputs would also need to be validated before they can be passed onto the next subroutines, which must also be taken into consideration.

It might be possible for several subroutines to be executed simultaneously within a program, and programmers must identify where this is possible by looking at the data and inputs the subroutine requires. Some subroutines will require data from other subroutines before they are able to execute, and so will be unable to execute simultaneously. In this case, programmers should determine the ​order in which subroutines are executed​, as well as ​how they interact with each other​, based on their role in solving the problem.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Decision making in problem solving

A

A ​decision ​is a​ result reached after some consideration​. When solving problems and designing programs, many decisions have to be made. One of the first and biggest decisions that is made is choosing the approach or ​paradigm used when developing a piece of software. Another example of decision making within software development is deciding how different pieces of information are collected.

Imagine you were set the task of building a program which
switches on a light when a button is pressed. What questions come to mind?
- Which programming paradigm will I use?
- Which programming language will I use?
- What input devices will I need?
- What output devices will I need?
- How can I interact with these devices?

To answer each of these questions, decisions have to be made. To simplify the decision making process, we begin by trying to​ limit the possible solutions​ we can pick from. When deciding on a programming language, for example, you should first consider which programming languages it is ​feasible ​for you to use. This decision should be based on the language’s suitability to the problem you are solving and whether it provides enough functionality to solve the problem. It is also important to consider which languages you are comfortable with using, or how easy it is to learn a new language given time constraints.

17
Q

Conditions that affect the outcome of a decision

A

When you make a decision, there are certain factors which ultimately determine the outcome you choose. There are several key factors that you should take into account:
- What is most effective?
- What is most convenient?
- Is this option reasonable?

To make an appropriate decision, you need to ​evaluate these conditions​ and order them from most important to least important. Once you have done this, it becomes easier to pick the best option for your solution. By prioritising either effectiveness, convenience or feasibility, it should become clearer what sort of approach is best for achieving your solution. This might vary depending on the purpose and end-users of the software.

18
Q

Decisions affecting the flow of a program

A

Decisions are made to determine how different parts of the program are completed. Say we are tasked with designing a simple runner game. We could design the game to be endless, or make the game level-based.

Again, we would evaluate these conditions using the methods described above. It is important to understand that both decisions produce completely different results, and therefore produce different routes through the program.

Thinking logically also involves identifying where decisions need to be made by the user within the program, and planning out the outcomes of the decision made. The program will follow a different route depending on the decision made by the user.

19
Q

Concurrent Thinking

A

Concurrent thinking is built upon the idea of ​concurrent processing​. It is the process of completing ​more than one task​ at any given time. This doesn’t necessarily mean that you have to be working on multiple tasks at once, which is the technique used by ​multicore processors​. Concurrent processing means different tasks are given slices of processor time, to give the illusion that tasks are being performed simultaneously, and concurrent thinking is the mindset that allows you to spot patterns and parts of problems where concurrency can be applied.
Below is an example illustrating this concept:
You are given two tasks:
1) Record the number plate of all the cars that pass you in a given time,
2) Record the colour of all the cars that pass you in a given time.

When tackling this problem, you could record every car’s number plate, then go back and record every car’s colour. However, the more sensible way of approaching this problem is to record the number plate of a single car and then record the colour of the same car, before moving on to the next car. This is an example of concurrent thinking.

20
Q

Concurrent Processing

A

The key difference between​ concurrent processing ​and​ concurrent thinking​ is that concurrent processing uses a ​computer processor​ while concurrent thinking means using your ​brain​ rather than a computer.

People often confuse ​concurrent processing​ and ​parallel processing​ as being the same thing, but they are slightly different. Parallel processing is when ​multiple processors​ are used to complete more than one task simultaneously. In contrast, concurrent processing is when each task is given​ a slice​ of processor time to make it look like the tasks are being completed ​simultaneously​ when in reality they are executed sequentially.

21
Q

Benefits and Drawbacks of Concurrent Processing

A

Benefits of concurrent processing
● The ​number of tasks completed in a given time​ is increased.
● Less time is wasted waiting​ for an input or user interaction, as other tasks can be completed.

Drawbacks of concurrent processing
● Concurrent processing can take longer to complete when large numbers of users or tasks are involved as processes cannot be completed at once.
● There is an​ overhead in coordinating​ and switching between processes, which reduces program throughput.
● Just as with parallel processing, not all tasks are suited to being broken up and performed concurrently.