5. Elements of computational thinking Flashcards
What is a Constant?
A Constant identifies a fixed value in memory.
What is a Variable?
A Variable identifies a value in memory which may change during the execution of the program.
What is Assignment?
Assignment is when a value is given to a Variable.
What is a Subroutine?
A Subroutine is a named block of code which can be called to perform a task.
What is a Function?
A Function is a Subroutine which returns a value when called.
Explain the use of a Call Stack in executing Subroutines.
The Call Stack is used for memory allocation when a Subroutine is called. A Subroutine requires the following data: Parameters, Local Variables, and the return address. This data is allocated as a Stack Frame on the Call Stack. Every time a Subroutine is called it is allocating memory, and Subroutines calling other Subroutines build up the size of the Call Stack. If the Call Stack gets too big there will be a Stack Overflow which will crash the program, this is particularly an issue with Recursive Subroutines.
What is a Parameter?
Parameters are Local Variables which hold the input values to a Subroutine. The values input into a Parameter are called Arguments.
What is a Module?
A Module is a grouping of related code into an independent unit, such as a file or library. It is often good practice to break complex programs into a series of Modules. These may also aid code re-use.
What is Representational Abstraction?
Representational Abstraction is the removal of detail from a problem until only the details required to solve the problem computationally remain.
What is Abstraction by Generalisation?
Abstraction by Generalisation is the grouping of common characteristics until a problem can be related (“is a kind of”) to a structure with known behaviour (such as a graph).
What is Data Abstraction?
Data Abstraction is the use of Abstract Data Types to structure data in the solution of a problem. An Abstract Data Type defines how its contents can be manipulated, but now how that behaviour is implemented. For example, a Stack Data Structure allows elements to be added (pushed) on to its top, or removed (popped) from its top, but could be implemented in several different ways (e.g. using an Array or a Linked List).
What is Procedural Abstraction?
Procedural Abstraction is the use of Procedures/Subroutines which solve a group of similar problems. Specific problems can be solved by specifying different inputs to the Procedure.
What is Decomposition/Composition?
Decomposition is the breaking a complex task into multiple sub-tasks which are simpler to solve. Composition is combining the solutions to simple tasks to solve a larger more complex task.
What is Concurrent Processing?
Concurrent Processing is when different aspects of the same problem can be solved at the same time.
What do Sequence, Selection/Branching and Iteration refer to?
Sequence - code is executed line by line from the top of the program to the end.
Selection/Branching - a choice is made between different possibilities, for example with an IF-statement.
Iteration - code is repeated using a loop structure, for example a FOR or WHILE loop.