questions on paper 2 Flashcards

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
Q

What makes a problem computable

A

If it can be solved by an algorithm

  • impractical when resources or time needed is too much
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

Graphs

A

An abstract data type that can be used to represent complex non linear relationships between objects

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

Similarities between graphs and trees

A

Both consist of node

Connected by edges

Non linear

Dynamic data structures

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

Differences between trees and graphs

A

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

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

Cycles

A

A path that starts and ends on the same node

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

Undirected edge

A

When there is no direction associated with an edge

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

Root

A

Start node for the traverse

32
Q

Uses of graphs

A

Graphs can be used to represent connections between real life objects e.g. towns and roads

33
Q

Decomposition

Definition

A

Breaking down large, complex problems into smaller subproblems

34
Q

Decomposition Advantages

A

Makes it easier to manage

Can be divided between a team

35
Q

Concurrent processing

What is it

A

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
Q

Advantages Concurrent processing

A

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
Q

Disadvantages Concurrent processing

A

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
Q

Pipelining

A

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
Q

Linear search

A

Checks every item one at a time O(n)

40
Q

Binary search

A

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
Q

Dijkstra’s

A

Shortest path between 2 nodes

Implemented using priority queue

42
Q

A*

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
Q

Recursion

A

When a program calls itself during its execution, continuing until a stopping condition is met

44
Q

Advantages and disadvantages of recursion

A

+ 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
Q

By ref

A

address of parameter is given to subroutine, value updated at given address

46
Q

by val

A

copy of value is passed to subroutine and discarded at end, value outside of subroutine remains unchanged

47
Q

Merge sort

A

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
Q

Quick sort

A

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
Q

Insertion sort

A

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
Q

Big o notation

A

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
Q

Time complexity

A

= 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
Q

Space complexity

A

= 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
Q

Bubble sort

A

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
Q

OOP vs Procedural

A

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
Q

Features of IDEs

A

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
Q

Finding errors

A

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
Q

Polymorphism

A

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
Q

Inheritance

A

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
Q

Object

A

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
Q

Methods (how to get and set a method)

A

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
Q

Attributes

A

data stored inside the class regarding the state or quality of the class or instance

Should be private so hidden withinga class

62
Q

Attributes

A

data stored within a class regarding the state or quality of the class or object

Should be private so hidden withing a class

63
Q

Access modifiers

A

Specify which properties can be accessed from outside the class

Private - wont allow you to assign a value

Public

Protected

64
Q

Classes

A

A blueprint that defines the properties of all objects of the same type

65
Q

Overriding

A

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
Q

Form of abstraction oop

A

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
Q

Instantiation

A

Making an object from the class definition

68
Q

Encapsulation

A

Binds together the attributes and the methods that manipulate the data

Form of data hiding

Doesn’t allow unintended alterations by other objects

69
Q

Stacks

A

Filo structure

Single pointer “top” points to element at top, initialised at –1

Size(), isempty(), peek(), push(element), pop()

70
Q

Queues

A

Fifo

2 pointers, front = first element, back = next available space

Size(), isempty(), peek(), enqueue(elements), dequeue()

71
Q

Oop

What is it

A

An approach to systems development that focuses on objects and the way that they interact

72
Q

Advantages of oop

A

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
Q

Disadvantages of oop

A

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
Q

Stepping

A

executing code a single line at a time

- allows you to monitor the effect of each line

75
Q

Variable watch

A

observe how the contents of a variable change in real time through the execution of a program

76
Q

break points

A

set a point where the program will stop

- helps pinpoint errors