Paper 1 Definitions Flashcards
Advantages of Subroutines (5)
- reduced amount of repeated code
- can concentrate on error fixing certain parts of the code at a time
- multiple programmers can work on the project at once
- once a function is finished the variables are deleted from memory so not so much memory is needed to run the program
- can use recursive methods e.g. sorting data
Process of Stack Frames (9)
- when a routine is called the computer allocated memory in a specialised region of memory called the ‘stack’
- every time a procedure is called by another procedure, a new stack frame for the procedure is pushed onto the stack
- stack frames contain copies of local variables in the parameters section
- the return address’ (variable’s) memory location is stored in the stack frame
- the stack frame stores the routine’s parameters and local variables until the routine ends
- when the routine ends:
- the value is stored to the return address
- control is passed back to the main function
- the stack frame is removed from the stack
2 Types of Programming Paradigms
- types
- descriptions
- examples
Imperative
- “we use instructions to say how to get the output we want”
- Procedural Programming: use subroutines, selection, sequence, iteration
- Object Orientated Programming: use objects and classes
Declarative Programming
- “we say what we want”
- Functional Programming
Advantages of OOP (6)
- data is protected by encapsulation
- an object can be changed without needing to change the objects that interact with it (improved software maintainability)
- class code is reusable
- improved software stability and consistency
- lower cost of development
- higher quality software
Disadvantages of OOP (5)
- harder to produce efficiently
- approach is not suited for all applications
- larger program size
- slower program execution due to increased instruction base
- can be difficult to apply over wide variety of applications
Class (definition)
- a group of objects with the same attributes and methods
- a blueprint to describe how the data type works
- an object definition
Instantiation (definition) (+ what happens)
The process of making an instance of an object
- usual for a constructor to run when an object is created
- this will set the values for the attributes of the object
Encapsulation is applied if (3)
- you need to prevent change to an object from external objects
- the internal complexity is not needed by other object and doesn’t affect their states
- (objects can communicate together but their implementation details are hidden from one another)
Multiple Inheritance (2)
- occurs when a class inherits from more than one parent
- gives more power to an OOP language as many base classes can be set up from which subclasses gain properties
Aggregation (definition)
A relationship between objects/classes where an object/class contains other objects/classes
- “has a” association between objects/classes
- lifecycle of the two objects/classes is independent
- - both exist in their own right (if one deleted the other still remains)
Composition (definition)
A relationship between objects/classes where an object/class contains other objects/classes
- “a part of” association between objects/classes
- life cycle of the object/class is dependent on the other object/class that contains it
- - if you remove the parent object/class then all child objects/classes are removed
Polymorphism (definition)
The ability of a programming language to process objects differently depending on their data type/class
- the ability of a method to exhibit different behaviours depending on the object on which the method is invoked
- allows different classes to be used with the same interface
Hash Table (definition)
Data structure that creates a mapping between keys and values
Dictionary (definition) (data type)
- a dictionary is a collection of key value pairs in which the value is associated via the associated key
- abstract data type
Convex Combination of Two Vectors
- finds a way to calculate points that lie on a line between 2 points
- 𝛂u + ꞵv where
- u and v are vectors
- 𝛂 + ꞵ = 1
- 𝛂 and ꞵ are >= 0
Procedural Abstraction (definition)
Represents a computational method
Actual values are replaced by parameters
Functional Abstraction (definition)
Hiding computational methods from the rest of the solution
Data Abstraction
A data object, e.g. a stack, hides the details of how the data is actually represented, e.g. the use of arrays and pointers, allowing the user to know how to use it and not on how it is constructed
“Backus Naur form does … “
“BNF can … “
“All regular languages can …”
- “Backus Naur form does not support iteration. It uses recursion instead”
- “All regular languages can be represented using a finite state machine without outputs”
- “BNF can represent some language that are not regular”
- e.g. palindromes, strings that have brackets of arbitrary depth
Turing Machines (3)
- An abstract concept of a machine capable of carrying out any computable algorithm
- A number, sequence or algorithm is computable if and only if a Turing machine can be described which is capable of computing it
- Any task that can be computed by any computer can be computed by a Turing machine
A UTM can be considered to be an interpreter as:
- it reads instructions one at a time
- and executes these instructions
- instructions are stored on the tape
Abstraction by Generalisation (definition)
Grouping of common characteristics
Information Hiding
Hiding the details of an object that does not contribute to its essential characteristics
Problem Abstraction
Details are removed until the problem is represented in a way that is possible to solve because the problem reduces to one that has already been solved