Fundamentals of Algorithms Flashcards

1
Q

What is Graph Traversal

A

Graph Traversal is the process of visiting each vertex in a graph.

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

What is an algorithm

A

A set of instructions which completes a task in a finite time and always terminates

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

Name the two types of graph traversal

A

Depth-first search and breadth-first search

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

Which type of graph traversal is best for a maze

A

Depth-first search

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

What is Breadth-first traversal useful for?

A

Shortest path on an unweighted graph

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

What abstract data type is used for a breadth-first traversal

A

Queue

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

What abstract data type is used in a depth-first traversal

A

Stack

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

What requirement must a graph have to be searched

A

it must be connected.

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

What is tree traversal

A

The process of visiting/updating/outputting each node in a tree

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

Name the three types of tree traversal

A

Preorder, inorder and postorder

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

Name a use of postorder tree traversal

A

Infinix to RPM
Producing a postfix expression from an expression tree

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

Name a use of inorder tree traversal

A

Outputting the contents of a binary search tree in ascending order

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

Can an inorder traversal be performed on any tree

A

no, it must be a binary tree, however postorder and preorder can be performed on any tree

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

How do tree traversals work their way around the tree?

A

anticlockwise

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

Why is reverse polish notation used

A

RPN eliminates the need for brackets, aswell as being easier to work with in computers.

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

Convert the following infix expression to reverse polish
14 + 6

17
Q

Convert the following infix expression to reverse polish
(12 - 4) x (3 + 5)

A

12 4 - 3 5 + x

18
Q

Convert the following reverse polish expression to infix
13 6 + 4 -

A

(13 + 6) - 4

19
Q

Convert the following infix expression to reverse polish
3(4 - 2) + 9

A

4 2 - 3 x 9 +

20
Q

Convert the following reverse polish expression to infix
4 6 7 + -

A

4 - (6 + 7)

21
Q

what is the result of this reverse polish expression
2 8 x 2 4 - x

A

(2 x 8) x (2 - 4) = -32

22
Q

What is the result of this reverse polish expression
4 6 8 - -

A

4 - (6 - 8) = 6

23
Q

Which searching algorithm requires data to be sorted before starting

A

Binary search

24
Q

What is the time complexity of a binary search

25
What searching algorithm has a time complexity of O(n)
Linear search
26
Which sorting algorithm is most time efficient: bubble sort or merge sort
merge sort
27
Which sorting algorithm is an example of a divide and conquer algorithm
merge sort
28
What is the time complexity of the bubble sort algorithm
O(n^2)
29
What is the time complexity of the merge sort algorithm
O(nlogn)
30
What is the purpose of an optimisation algorithm
To find the best possible solution to the problem posed.
31
What is the purpose of Dijkstra's algorithm
To find the shortest path between two nodes in a network