The Worst Topics Flashcards

1
Q

What order does pre order tree traversal go in?

A

N L R

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

What order does in order tree traversal go in?

A

L N R

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

What order does post order tree traversal go in?

A

L R N

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

Name this notation and the traversal required to get this

2 + 3

A

Infix

In order traversal

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

Name this notation and the traversal required to get this

2 3 +

A

Reverse Polish

Post order

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

Name this notation and the traversal required to get this

+ 2 3

A

Polish

Pre order

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

What is open addressing?

A

Use hashing to find a candidate bucket, have a strategy to remap colliding keys and find them afterwards

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

What is secondary hashing?

A

Use a second hash function to pick the bucket, if there is still a collision, then revert to linear probing

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

What is linear probing?

A

Walking along the bucket until you find a free space to place the key/value pair

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

What is separate chaining?

A

The bucket is a list of key/value pairs. We hash to the bucket and then add it to the list at the position.

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

What is extendable hashing?

A

Process of splitting the bucket, consuming another bit of the hash code, and placing values in the newly split parts of the bucket

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

What features do we want from a hash function?

A
  • Two keys that are close together, map far apart
  • Low chance of two keys mapping to the same value
  • Spread of the keys across the hash bucket
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Describe the parsing pipeline

A

Source Text
Tokeniser
Parser
Parse tree

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

Describe the process of tokenising using a FSA

A

Tokenise the input source, generating a steam of tokens for the grammar, some tokens can carry values with them
FSA keeps track of the characters used, attaches them to the recognised symbol

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

Describe the process of recursive descent parsing

A

Treats each production as a small recogniser that looks at the token stream and tries to recognise itself
Try it and see it method

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

What is the job of terminal recognisers in recursive descent parsing?

A

Check if the current token in the token stream is the expected one

17
Q

What is the job of non terminal recognisers in recursive descent parsing?

A

Checks compound patterns, repetitions etc and saves and rewinds the token stream

18
Q

What are the four functions needed for recursive descent parsing?

A

nextToken()
advanceTokenStream()
getTokenStreamPosition()
setTokenStreamPosition()

19
Q

Describe the process of table driven parsing

A

Start with the tokens, see which productions could have given rise to them
Build the tree as a constraints problem

20
Q

What are the advantages of table driven parsing?

A
  • Smaller and faster

- No need for back tracking

21
Q

What are the disadvantages of table driven parsing?

A
  • Less clear

- Can be tripped up easily

22
Q

Describe the divide step in a divide and conquer algorithm

A

Take a problem S and split it into two smaller problems S1 and S2

23
Q

Describe the recurse step in a divide and conquer algorithm

A

Recursively solve S1 and S2, either directly (the base case of the recursion) or by further division

24
Q

Describe the conquer step in a divide and conquer algorithm

A

Combine the solutions to S1 and S2 into a solution to S

25
Q

Define polymorphism

A

Some values and variables may have more than one type

26
Q

What are the two categories of polymorphism?

A

Ad hoc and Universal

27
Q

What are the two types of Ad hoc polymorphism?

A

Overloading

Coercion

28
Q

What are the two types of Universal polymorphism?

A

Inclusion

Parametric

29
Q

What are the advantages of polymorphism

A
  • Allows methods to perform similar tasks accessed under a common name
  • Allows you to define multiple constructors
  • Less repetition of code
30
Q

Describe overloading polymorphism

A

Same function name is used to denote different types, operators can be applied to operands of different types e.g. +

31
Q

Describe coercion polymorphism

A

Instance of one type forced to be interpreted as another e.g. if * could only be applied to real numbers, int types converted

32
Q

Describe inclusion polymorphism

A

Instance of a subtype can be manipulated as if it was an instance of the supertype

33
Q

Describe parametric polymorphism

A

Code features an implicit or explicit type parameter, coed can be used for value of any suitable type, does not depend on value at run time

34
Q

Describe the collections framework

A

Unified architecture for representing and manipulating collections
Contains algorithms, interfaces and implementation

35
Q

Benefits of the collections framework

A
  • Reduced programming effort
  • Reliable and optimised
  • Standard interfaces, so less to learn
  • Implementation of each interface interchangable
36
Q

What are the three design goals of the collection framework

A
  1. Produce a reasonably small API (size and conceptual weight)
  2. Small number of core interfaces
  3. Only have methods if they are truly fundamental or there is a compelling performance reason
37
Q

Describe a factory

A

A factory is an OO design pattern that deals with creating objects without specifying the exact dates of object that is to be created

38
Q

What are the benefits of using factories?

A
  1. Allows for a lot more long term flexibility, able to easily change application
  2. Makes your code more testable, can mock interfaces and decoupled design
  3. Makes rest of code easier to write, modify and maintain
39
Q

What is a parse tree?

A

Illustrated, pictorial version of the grammatical structure of the sentence.
Diagrammed form of a sentence, and gives an concrete idea of the syntax of that particular sentence