questions on paper 2 Flashcards

(76 cards)

1
Q

Abstraction

A

The process of separating ideas from particular instances/reality.

A way of hiding details/only using relevant details.

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

Representational

A

Representation of reality using symbols to show real life features.

Irrelevant info left out / excessive details removed so only key features remain

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

Procedural

A

Utilising functions and procedures without knowing how they are implemented

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

Generalisation

A

Grouping together similarities within a problem and then solving it via a general solution

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

Data abstraction

A

Details about how data is being stored are hidden

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

Differences between abstraction and reality

A

Abstraction is a simplified representation of reality

Scenery simplified, damage/litter removed

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

Advantages of abstraction

A

Reduces programming time, and program size, reduces memory requirements

Keeps focus on core aspects of program – doesn’t detract from main purpose

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

Disadvantages of abstraction

A

Too much can make the program too simplistic

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

Reusable code

A

Software is modular e.g. functions

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

Advantages of reusable code

A

Modules can be transplanted into new software or can be shared at run time through the use of libraries

More reliable as already tested

Save time, money and resources

Teams can work on large projects

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

How does it help beginners (reusable code)

A

Hides complex and irrelevant info so they can us the system without knowing how it works

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

When are lots of layers of abstraction needed and what is this called

A

Large complex problems

Stepwise refinement/Top down development

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

What makes a tree a binary tree

A

Each node has only 2 child nodes

It is ordered to optimise searching

Has no cycles

Edges not directed

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

Edges

A

The ‘lines’ and connections that link 2 nodes

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

How to search a binary tree

A

Compare required element with root node. If it is less, search the right tree, if more search the right tree. Repeat until you reach leaf or you find the item

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

Pointers and notes

Advantages

A

make algorithm easier to trace, can help with testing and maintenance, allows others to understand system

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

Tree traversal

A

Systematically visiting every node

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

Depth first tree traversal

A

Goes down one branch of the tree as far as possible until it stops at a leaf before trying another branch

Uses a stack

Left, then right, then itself

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

Breadth first tree traversal

A

The tree is traversed by sweeping through the breadth of a level before visiting the next level down

Starting from left, visits all children of the start node

Then it visits all nodes directly connected to each of these nodes

Uses a queue

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

Pre order

A

Visit node

Pre order of left tree

Pre order of right tree

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

In order

A

In order of left tree

Visit node

In order of right tree

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

Post order

A

Post order of left tree

Post order of right tree

Visit node

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

Uses

Binary search trees

A

in order = access values in ascending order

   - reverse in order = descending order
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

Algorithms

Definition

A

a set of instructions followed to complete a task

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
What makes a problem computable
If it can be solved by an algorithm - impractical when resources or time needed is too much
26
Graphs
An abstract data type that can be used to represent complex non linear relationships between objects
27
Similarities between graphs and trees
Both consist of node Connected by edges Non linear Dynamic data structures
28
Differences between trees and graphs
Tree = 1d, graph = 2d Tree has root node, graph has no clear root Trees are not weighted whereas graphs can be Graphs can have cycles whereas trees cannot
29
Cycles
A path that starts and ends on the same node
30
Undirected edge
When there is no direction associated with an edge
31
Root
Start node for the traverse
32
Uses of graphs
Graphs can be used to represent connections between real life objects e.g. towns and roads
33
Decomposition Definition
Breaking down large, complex problems into smaller subproblems
34
Decomposition Advantages
Makes it easier to manage Can be divided between a team
35
Concurrent processing What is it
Each task is given a slice of processor time to make it appear as if tasks are being completed simultaneously One processes does not have to finish before the other starts
36
Advantages Concurrent processing
number of tasks completed in a given time increases + less time wasted waiting for user input/ interaction as other tasks can use processor while waiting
37
Disadvantages Concurrent processing
Can take tasks longer to complete when large numbers of users or tasks are involved Overhead in coordinating and switching between processes reduces program throughput Not all tasks are suited to being broken up
38
Pipelining
Different tasks developed in parallel, faster project delivery Commonly used in risc processor (fde simultaneously) Output of one process is the input of another
39
Linear search
Checks every item one at a time O(n)
40
Binary search
Divide and conquer O(logn) 0nly works in sorted lists Find middle element Compare If smaller use left sub list If bigger use right sub list Repeat until item is found or the are no more elements to check
41
Dijkstra's
Shortest path between 2 nodes Implemented using priority queue
42
A*
Improvement of Dijkstra's Two cost functions – actual cost and heuristic (approximate cost) Heuristic added to actual cost to determine which node is visited Efficiency of algorithm depends on accuracy of heuristics
43
Recursion
When a program calls itself during its execution, continuing until a stopping condition is met
44
Advantages and disadvantages of recursion
+ can be represented in fewer lines of code + easier to express some functions recursively e.g. factorials Risk of stack overflow if memory runs out Difficult to trace
45
By ref
address of parameter is given to subroutine, value updated at given address
46
by val
copy of value is passed to subroutine and discarded at end, value outside of subroutine remains unchanged
47
Merge sort
Divide and conquer Splits list in half until all sub lists have length 1 Merge puts them back together so they are in order O(nlogn)
48
Quick sort
Select an element (often middle) called pivot Divides input around pivot Smaller than pivot = added to left list Bigger than pivot = added to right list Repeated recursively until all elements in input are old pivots or list length = 1 O(n^2)
49
Insertion sort
Compare item to later ones in list an insert it in correct place In the nth iteration, the first n numbers are sorted (this doesn’t mean they are the smallest numbers) Must go through whole list O(n^2)
50
Big o notation
Constant - same time regardless of data set Logarithmic - halves data set in each pass – good with large sets Linear - performance proportional to data Polynomial - performance proportional to square of size of data set Exponential - time doubles with each addition to the data set
51
Time complexity
= Big O The time is takes for the algorithm to solve the problem – worst case scenario To reduce, reduce the number of embedded for loops
52
Space complexity
= amount of storage the algorithm uses to run – stores extra data whenever it makes a copy of data To reduce, perform all changes on the original data
53
Bubble sort
Evaluates pairs of items O(n^2) Comparisons and swaps between pairs To improve efficiency, a flag recording whether a swap has occurred can stop it having to loop through all the data items
54
OOP vs Procedural
OOP – problem divided into smaller parts called objects - systems are built around objects - objects don’t share data Procedural – problem divided into smaller parts called procedures Systems are built by combining procedures Procedures share data between them through global variables
55
Features of IDEs
A program which provides a set of tools to make it easier for programmers to write, develop and debug code Stepping Variable watch Debugging tools Break points
56
Finding errors
Limit the length of a function to less than 1 page to aid readability and reduce complexity Variable identifiers must conform to standard convention – helps other understand the code, reduces the likelihood of duplication, makes maintenance easier Each function must have a single entry point to reduce complexity and makes the search for bugs more straightforward Variables must not be set up outside the scope of a function, sets a limit where to look for bugs and reduces likelihood of problems spreading across many modules
57
Polymorphism
The ability of a method to exhibit different behaviors depending on the object on which the method is involved e.g. how the plus sign changes from meaning concatenation when working with strings and mathematical addition when working with integers
58
Inheritance
Maks it possible to create a new child class that take on (inherits) the attributes and methos of the original (parent) class. Means that attributes and methods don’t need to be redefined + reduces repeated code +if implementation details need to change, it only needs to happen in one place May have unintended consequences (someone may extend the base class or make the bass class inherit from another class) meaning acquiring attributes and methods you’re not aware of
59
Object
An instance of a particular class Collaborate with each other by sending and receiving messages All of the data and procedures and functions belong to one or more objects
60
Methods (how to get and set a method)
# define every operation that is allowed to be carried out on an attribute Getters (accessors) – returns the value of an attribute Setters (mutators)– let you change the value of an attribute If no setters are provided there is no way that a value can be changed Public methods are used to access or modify attributes
61
Attributes
data stored inside the class regarding the state or quality of the class or instance Should be private so hidden withinga class
62
Attributes
data stored within a class regarding the state or quality of the class or object Should be private so hidden withing a class
63
Access modifiers
Specify which properties can be accessed from outside the class Private - wont allow you to assign a value Public Protected
64
Classes
A blueprint that defines the properties of all objects of the same type
65
Overriding
Happens automatically when you call a method from an object that shares the same name as a method further up the class tree. The overriding method takes precedence and replaces the method from the superclass
66
Form of abstraction oop
The inner workings ad details of the class don’t need to be understood by anyone other than the class designer. Classes often provided as part of software libraries.
67
Instantiation
Making an object from the class definition
68
Encapsulation
Binds together the attributes and the methods that manipulate the data Form of data hiding Doesn’t allow unintended alterations by other objects
69
Stacks
Filo structure Single pointer “top” points to element at top, initialised at –1 Size(), isempty(), peek(), push(element), pop()
70
Queues
Fifo 2 pointers, front = first element, back = next available space Size(), isempty(), peek(), enqueue(elements), dequeue()
71
Oop What is it
An approach to systems development that focuses on objects and the way that they interact
72
Advantages of oop
Easier for us to think in terms of objects rather than procedurally Prewritten classes support code reuse Classes can easily be extended by creating a child Highly modular so can be split between teams Encapsulation provides protection
73
Disadvantages of oop
Result in larger, more complex systems Relies on high volume of message passing so can be detrimental to performance Objects can take up a large amount of memory
74
Stepping
executing code a single line at a time | - allows you to monitor the effect of each line
75
Variable watch
observe how the contents of a variable change in real time through the execution of a program
76
break points
set a point where the program will stop | - helps pinpoint errors