PAPER 2(exam qs) Flashcards

1
Q

why does a recursive algorithm take up more storage compared to iterative(2)

A
  • each recursive call creates new variables
  • iteration reuses the same variables
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

what must you always do when a stack is full or empty

A

display message of it being full/empty

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

what are the similarities between classes and records

A

both store data of different types

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

what is concurrent processing(2)

A
  • processes appear to be happening simultaneously
  • giving processes a slice of processor time
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

hwo do we know if data is fully sorted in a bubble sort

A

if there is no swaps

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

what are the benefits and drawbacks of using iteration compared to recursion

A

BENEFIT: cannot run out of memory
DRAWBACK: iteration can lead to lengthier code. harder to understand

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

why might insertion sort use less memory compared to merge sort

A
  • merge sort might create a new array each time it splits and merges
  • insertion sort doesnt use any new arrays
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

what are error diagnostics

A

messagesfrom the compiler to the programmer

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

what is thinking ahead

A

identifying the precondition, inputs and outputs of a system

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

what does openWrite(x.txt) mean

A

open the file x for writing data

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

what are advantages of pseudocode

A
  • doesn’t matter if it contains syntax errors
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

what is a disadvantage of backtracking

A

only useful for sequential problems

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

what is the best searching algorithm on average

A

hashing function

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

what is the difference between get and set methods

A
  • get methods allow attributes to be acessed
  • set methods allow attributes to be changed
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

hwo do we know if a linked list is empty

A

if the head pointer is null

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

what are the 3 benefits of uising OOP

A
  • allow for code reusability
  • allows programs to be easier modified and maintained
17
Q

why are things passed by reference(2)

A
  • allows contents to be modified
  • uses less memory
18
Q

what has to be implemented into sorting algorithms so they do not tuurn recursive

A
  • set a flag if swaps are made(set it to false)
19
Q

what is problem recognition

A

identifying requirements to solve a problem

20
Q

what is an operator

A

a character that represents an action

21
Q

Which data structure is necessary to perform a depth first search of a tree or graph

A

a stack

22
Q

what is a limitation of performance modelling

A
  • requires accurate data
23
Q

why is heuristics usually applied

A

when the problem takes too long or too expensivve to achieve

24
Q

what is pattern recognition

A

when you look for similarities between different problems

25
Q

how can abstraction be used when actually programming a solution

A

deciding which variables and routines are needed

26
Q

what is parallel processing

A

when different processing units process diffferent tasks at the same time

27
Q

why are constructors used

A

to create an instance of an object from a class

28
Q

what is the name given to top classes and under classes

A
  • super class
  • sub class
29
Q

what is the difference between by reference and by value

A
  • by reference the function receives the memory location of the data
  • by value the function receives the copy of the variable
30
Q

what is one advantage and disadvantage of using global variables

A

advantage: can be accessed from anywhere in the program
disadvantage: increases memory usage as it is used until full program execution is over

31
Q

what are 2 features which are provided by the IDE which help to write code

A
  • auto complete(fill in the rest when the command is being typed in)
  • auto indent(indents code to help avoid errors)
32
Q

difference between directed and undireted graphs

A
  • in directed edges may only go in one direction
  • in undirected edges can go in both directions
33
Q

what are the similarities between A* and Dijkstras(2)

A
  • both are path finding algorithms
  • both find the shortest route
34
Q

what are the 2 features of any recursive algorithm

A
  • a function that calls itself
  • has a base case(a condition that terminates the algorithm through furtehr recursions)