What are factorials?
5! (spoken 5 factorial) is a shorthand way of expressing the product of numbers 1 to 5:
- 5! = 5 x 4 x 3 x 2 x 1
- 0! = 1
What is a recursive subroutine?
A subroutine that contains itself.
A recursive subroutine has three essential characteristics:
- A stopping condition or base case must be included which when met means that the routine will not call itself and will start to “unwind”,
- For input values other than the stopping condition, the routine must call itself,
- The stopping condition must be reached after a finite number of calls.
How do recursive subroutines work with the call stack?
What is an example of a recursive algorithm?
Tree traversal algorithms.
What are two ways to measure how efficient a program is?
What is Big-O notation?
Big-O notation is a measure of the time complexity of an algorithm, it is a useful approximation of the time taken to execute an algorithm for a given number of items in a data set.
- There is no such thing as, for example, O(2n + 1),
- Only the dominant term counts, so it is O(n).
What is a permutation?
A permutation of n items is the number of ways the n items can be arranged.
What are the types of permutations?
What are the two ways of traversing a graph?
What is depth-first traversal?
You go as far as you can down a path before backtracking and going down the next path.
What is breadth-first traversal?
You explore all the neighbours of the current vertex, then the neighbours of each of those vertices and so on.
What is Dijkstra’s shortest path algorithm?
The algorithm is designed to find the shortest path between a start node and every other node in a weighted graph.
What are computable problems?
A problem is defined as being computable if there is an algorithm that can solve every instance of it in a finite number of steps.
Some problems may be theoretically soluble by computer but if they take millions of years to solve, they are, in a practical sense, insoluble.
What imposes limits on computations?
What is The travelling salesman problem (TSP)?
“Given a list of towns and the distances between each pair of towns, what is the shortest possible route that the salesman can use to visit each town exactly once and return to the starting point?”
What are tractable problems?
A problem that has a polynomial-time solution or better is called a tractable problem.
What are intractable problems?
An intractable problem is one that does not have a polynomial time solution.
Although the problem may have a theoretical solution, it is impossible to solve it within a reasonable time for values of n greater than something very small.
What is a heuristic approach?
A heuristic approach is one which tries to find a solution which may not be perfect but which is adequate for its purpose.
What is the Halting problem?
This is the problem of determining for a given input, whether a program will finish running or continue for ever.