Comp 2 Flashcards

1
Q

What is single processor concurrency?

A

A processor that processes sequentially but can switch very quickly between processes hence giving an impression of parallel processing.

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

What is multiprocessor concurrency?

A
  • Processes can be processed concurrently

- Programs are broken down into sub programs and places in a queue to avoid synchronisation problems.

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

Advantages and disadvantages of multiprocessor concurrency?

A

Advantages:
- Increased speed as more then one process can be process at a time

  • Utilised in divide and conquer algorithm
  • Less wait time for input/output operation as during relevant processes can be executed

Drawbacks:
- Difficult to identify where it can be implemented in a program

  • Harder to debug and test as some errors are time related
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the main difference between functions and procedures?

A

Functions return values where as procedures generally do not.

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

Advantages of functions/procedures?

A
  • Less code needs to be written as no need to repeat code

- Easier to read and understand when monitoring and fixing code

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

What is a parameter?

A

A parameter is an variable passed to a function.

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

What does it mean to pass a variable by reference?

A
  • ByRef means that when the variable is passed it is passed by reference from memory.
  • Any changes made are saved to memory.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What does it mean to pass a variable by value?

A
  • By value means that any changes made to variable in the function is not saved in memory
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Describe the four types of abstraction?

A

Procedural: Breaking problems into sub-problems

Functional: Utilising in-built functions from library

Data: Isolation how data is created and how it behaves

Problem: Problems removed until it’s straightforward and simple.

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

Describe a repeat until loop.

A

A repeat until loop is always executed at least once.

At the end of the program the condition is tested and repeats until no longer true.

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

Compare recursive solution to a iterative solution.

A
  • Recursive solutions have fewer variables

- Harder to understand making it harder to maintain

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

What is a variable?

A

A space in memory that holds a value which can be changed during the execution of the program.

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

What is a local variable?

A

Local variables are variables only available to the function they are coded in.

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

What is a global variable?

A

A variable that is available to the whole program.

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

Compare the use of global and local variables?

A

Global should only be used if there is use of value throughout program as otherwise it hard to trace and uses up memory unnecessarily.

Local variables are more memory efficient as only take up memory when used.

Easy to trace as it promotes modularity.

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

Advantages of modularity?

A
  • Breaking down a problem into sub-programs saves development time as more than one person can work on it at a time.
  • Debugging and testing easier as less time spent locating errors
  • Programs are easier to understand and maintain.
  • Any new features are easy to add.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What are declarative languages?

A

A language which expresses structure and logic of computation without control flow.

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

What is backtracking?

A

When a programmer searched different logical pathways until the correct one is found. Trial and error approach.

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

What is Heuristics?

A

Rule of thumb/educated guess approach which is used when unfeasible to analyse
all eventualities.

This leads to a “good enough” result
although it is not 100% reliable

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

What is pipelining?

A

Next instruction being fetched even though current instruction is not yet finished executing.

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

What is caching?

A

Commonly used instructions stored in fast memory storage. Web pages can be stored this way.

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

What are the benefits and drawbacks of caching?

A

+ Reduces execution time as data can be accessed faster.
+ Faster then RAM

  • Can produce stale data.
  • Very expensive
  • Small compared to RAM
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

What does a precondition consist of?

A

Name:
Input:
Output:
Precondition:

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

What are the advantages of preconditions?

A

Documentation helps maintain and understand the code.

User can know the checks that need to carried out before subroutine is called.

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

Explain the Dijkstra algorithm.

A

1) Select a start node
2) Give start node a value of 0 and all other nodes a value of infinity.
3) Place nodes into a queue.
4) Remove start node and neighbour node.
5) startNode = u & neighbourNode= w

6) newDistance = distanceAtU + distanceUToW
if newDistance < distanceAtW
distanceAtW = newDistance

7) Queue changes to reflect this

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

Describe what is meant by recursion.

A

The function calls itself from within the function.

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

Explain advantages of using reusable components.

A
  • Modules already tested so more
    reliable programs.
  • Less development time as programs
    can be shorter and modules can be
    shared
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

What are the three types of modelling?

A
  • Physical
  • Process
  • Mathematical
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q

Explain Physical modelling.

A

Real life objects represented as scale models to see how they behave in certain situations

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

Explain Process modelling.

A

Used to predict delays and physical limitations

Solution can be improved and changed the addition of more physical factors

31
Q

Explain mathematical modelling.

A

Computer program runs a simulation modelling a situation

32
Q

What is representational abstraction?

A

Unnecessary information removed leaving only information required to solve problem

33
Q

What is generalisation abstraction?

A

Problem simplified by grouping similar parts into hierarchical structure.

34
Q

What is function abstraction?

A

Exact computational method is hidden

35
Q

What are sub-procedures?

A

Block of code that solves a small part of the problem/aim of the program.

36
Q

What are the advantages of using sub-procedures?

A
  • Use of sub-procedures aids readability and making main program appear less complex.
  • Can be re-used in other parts of program
  • Can be treated as object with own task
  • Can be developed independently of other code
37
Q

What is multi threading?

A

Technique where by particular section of code can be used by numerous processors at different stage of execution.

38
Q

How does sequence structures work?

A

Program executes each statement or function in order.

39
Q

How does branching/selection structure work?

A

Selection structure is where program executes different actions or statements on result of a comparison

40
Q

What is an IDE?

A

An integrated development environment (IDE) provides a range of tools for a computer to develop high level language software.

41
Q

What are the features of an IDE?

A
  • Syntax highlighting
  • Spell check
  • Error diagnostics
  • Source editor
  • Break points
  • Auto documentation
42
Q

What is a class?

A

A class describes attributes and methods and is a template that can be used to create objects

43
Q

What is an object?

A

Contains data and operations for a real world object.

  • Instance of a class
44
Q

What is encapsulation?

A

Combination of data and operation into an object

45
Q

What is inheritance?

A

A sub class inherits the attributes and methods of a parent class.

46
Q

What is polymorphism?

A

Permits different objects in a class to be process differently.

47
Q

What are advantages of using OOP?

A
  • Written using modules based on objects making it easy to follow and modify if needed
  • Modular nature allows more then one person to work at same time
  • New function added simply by creating new class or object
  • Class only concerned with data within, unlikely to access any other data
  • Data can be hidden within a class providing better security
  • Inheritance makes code reusable and less code needed
48
Q

What are advantages of decomposition?

A
  • Breaking problem down into parts helps clarify what exactly needs to be achieved.
  • Each break down makes problem easier to fix
  • Some functions may be reusable
  • Allows more then one person to work on it at the same time
49
Q

Disadvantages of decomposition?

A
  • Solutions to a problem may not combine to produce solution to initial problem
  • A problem that is complex and misunderstood is difficult to breakdown.
50
Q

What is data mining?

A

Analysing data to find patterns, trends and relationships

51
Q

What is data warehousing?

A

Used in conjunction with data mining, combines data from different sources into comprehensive database that aids easy handling.

52
Q

What is visualisation?

A

Technique where by visual model or image used to display problem and data.

53
Q

What is the suitability, time complexity and space complexity of bubble sort?

A

Suitability:

  • Requires little memory, useful in embedded system
  • Only suitable for small data sets, as larger size takes longer

Time complexity:

  • Most inefficient
  • O(N^2)

Space complexity:
- O(1)

54
Q

What is the suitability, time complexity and space complexity of insertion sort?

A

Suitability:

  • Efficient for small data sets
  • Faster then bubble sort for all data
  • Takes longer with large data set

Time complexity:
- O(N^2)

Space complexity:
- O(1)

55
Q

What is the suitability, time complexity and space complexity of merge sort?

A

Suitability:
- Divide and conquer algorithm suitable for large data sets

Time complexity:
- Fast O(N log(N))

Space complexity:
- O(N)

56
Q

What is the suitability, time complexity and space complexity of quickSort?

A

Suitability:

  • Efficient for any length of data
  • Divide and conquer algorithm

Time complexity:
- O(N log(N))

Space complexity:
- O (Log(N))

57
Q

What is the suitability, time complexity and space complexity of Dijkstra?

A

Suitability:
- Shortest distance between two points on map

Time complexity:

  • Longer with more vertices
  • O(E Log (V))

Space complexity:
- O (V + E)

58
Q

What is the suitability, time complexity and space complexity of A* algorithm?

A

Suitability:

  • Shortest distance between two points but faster
  • Faster because of heuristics

Time complexity:
- O(E)

Space complexity:
- O(V)

59
Q

What is the suitability, time complexity and space complexity of Linear Search?

A

Suitability:

  • Can handle data that is unordered
  • Can take long as it starts from beginning

Time complexity:

  • O(N) (WORSt)
  • O(N/2) (AVERAGE)

Space complexity:
- O(N)

60
Q

What is the suitability, time complexity and space complexity of Binary Search?

A

Suitability:

  • Data has to be in order
  • Otherwise faster

Time complexity:

  • O(Log (N)) (WORST)
  • O(1) (BEST)

Space complexity:

  • Iterative O(1)
  • Recursive O(Log(N))
61
Q

What are the features of Stacks?

A
  • Used as temporary storage for functions and sub-routines
  • LIFO
  • Stores data not needed in function
62
Q

What are features of Queue?

A
  • Temporary storage of data (Buffer data)

- FIFO

63
Q

What are features of Linked lists?

A
  • Linear data structure
  • Dynamic data structure
  • Pointers link data elements
  • Node = element in linked list
  • Head pointer = Points to first node and head node
  • Link = each node contains link detailing location of next node
  • Null = Last node in linked list
64
Q

What are features of a tree structure?

A
  • Root = Starting node
  • Parent = node in tree has nodes attached to it
  • Child = node has single node above
  • Leaf = Node has no node below it
65
Q

What is a binary tree?

A

Tree structure where each node has no more then two child nodes.

66
Q

What is depth first tree traversal?

A

Process for traversing tree data structure go left most sub tree until exhausted then move onto right sub tree.

67
Q

What is breadth first tree traversal?

A

Start at root then move down each level.

68
Q

What are the advantages and disadvantages of bubble sort?

A

Advantages:

  • Useful when little memory required
  • Easy to code, understand and implement

Disadvantage:

  • Max (N-1) searches to fully sort
  • Very time consuming for large data sets
69
Q

What are the advantages and disadvantages of Insertion Sort?

A

Advantage:

  • Simplest sort algorithm
  • Efficient with small data sets
  • More efficient then bubble sort

Disadvantage:
- Large number of element shifts required, if high number of elements performance decreases

70
Q

What are the advantages and disadvantages of merge sort?

A

Advantage:
- Fast

Disadvantage:
- Uses additional temporary storage space to hold merged data, problem with long lists

71
Q

What are the advantages and disadvantages of quick sort?

A

Advantage:

  • Fast
  • Little additional space is needed

Disadvantage:

  • Choice of pivot directly affects performance
  • Recursion partitioning hard to implement and code
72
Q

What are the uses of Dijkstra algorithm?

A
  • Determining shortest route between two places on map

- Determining shortest route for data packet in network

73
Q

What is A* algorithm formula?

A

f(x) = g(x) + h(x)

x = last node on path
g(x) = length of path from start node
h(x) = heuristic function used to estimate distance from current node to goal node