1.3 Fundamentals of algorithms Flashcards

1
Q

Define implementation

A

Creating code to produce a programmed solution

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

Define depth first graph traversal

A

A method for traversing a graph that starts at a chosen node and explores as far as possible along each branch away from the starting node before backtracking to visit unvisited nodes. It is often implemented with a recursive algorithm

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

Define breadth first graph traversal

A

A method for traversing a graph that explores nodes closest to the starting node first before progressively exploring nodes that are further away. A queue is used to keep track of the nodes to visit

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

What are the 3 ways of traversing a binary tree and their uses?

A
  • Pre-order: Can be used with expression trees to evaluate the expression using prefix notation
  • In-order: The equivalent of a binary search of the tree
  • Post-order: Will produce Reverse Polish Notation
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Define traversal

A

The process of reading data from a tree or graph by visiting all of the nodes

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

Define pre-order traversal

A

A method of traversing a tree by visiting the root, traversing the left subtree, and traversing the right subtree

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

Define in-order traversal

A

A method of traversing a tree by traversing the left subtree, visiting the root, and traversing the right subtree

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

Define post-order traversal

A

A method of traversing a tree by traversing the left subtree, traversing the right subtree, and then visiting the root

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

What are base and general cases of recursion?

A

A base case of a recursive function is the point at which the function will stop calling itself. The general cases of a recursive function are all the other cases of the function where it calls itself

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

Define single source

A

In the Dijkstra’s algorithm it means that the shortest path is calculated from a single starting point

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

Define shortest path

A

The shortest distance between two vertices based on the weighting of the edges

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

Define linear search

A

A simple search technique that looks through data one item at a time until the search term is found

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

Define binary search

A

A technique for searching ordered data that works by splitting datasets in half repeatedly until the search data is found

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

Define binary tree search

A

A technique for searching a binary tree that traverses the tree until the search term is found - it will move down the tree depending on if the target node is expected to be found on the left or right of the current node

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

Define infix notation

A

Expressions that are written with the operators within the operands

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

Define postfix notation

A

Expressions that are written with the operators after the operands - this is also known as Reverse Polish Notation

17
Q

Define prefix notation

A

Expressions that are written with the operators before the operands - this is also known as Polish Notation

18
Q

Why is Reverse Polish Notation used?

A

An interpreter has no inherent undersanding of the order of mathematical operations, so by using RPN, the need for brackets is removed, and operations can be processed

19
Q

How do the locations of operands in expressions link to binary trees?

A
  • In-order traversal of a binary tree of an expression would give an expression in infix format
  • Post-order traversal of a binary tree of an expression would give an expression in RPN
  • Pre-order traversal of a binary tree of an expression would give an expression in Polish Notation
20
Q

How do you evaluate RPN?

A

Commonly RPN is evaluated using a stack

21
Q

Define bubble sort

A

A technique for putting data in order by repeatedly stepping through an array, comparing adjacent elements and swapping them if necessary until the array is in order

22
Q

Define merge sort

A

A technique for putting data in order by splitting lists into single elements and then merging them back together again