Unit 8- Algorithms Flashcards

1
Q

What does Big O Notation measure?

A

Time Complexity

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

What is the time complexity of an algorithm with two nested loops?

A

O(n^2)

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

What is the big O notation for the most efficient algorithms and why is this often unrealistic?

A

O(1), if the algorithm inputs numbers, it is hard to make an algorithm which isn’t affected by the size of the number, however this isn’t never, accessing data in an array for example doesn’t matter how large the number is (as long as its in the array it will take the same amount of time to access)

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

If two algorithms have the same big O notation, do they take the same amount of time to run?

A

No, for example an algorithm that takes 2n seconds to run, has the same big O notation as one that takes 3n+16.

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

What is recursion?

A

Recursion is when a subroutine calls itself from within the subroutine.

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

What must recursive subroutines contain?

A

They must have a stopping condition (or a base case) which will make it unwind so that it does not go on forever. It must stop after a finite number of calls.

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

What three things do call stacks hold?

A

Return adresses, parameters, and local variables.

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

Types of tree traversals:

A

In-order, pre-order, post order.

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

Step of Djkstras Algorithm

A
  1. Create a queue of all starting nodes with the starting node at the front and add to each their distance from starting node.
  2. Remove the front node and add to the visited list
  3. Update the distances of each node connected to the visisted node
  4. Reorginise the queue so that the nodes are ordered in terms of their distance (shortest first)
  5. Repeat the steps above until all nodes have been visisted(moved to the front and dropped down to the visisted list)
  6. You will be left with a lists of nodes and there shortest distance from there starting nodes.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is a tractable problem?

A

A problem that has a polynomial time complexity or better,

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

What is a computable problem?

A

Computatble problems are problems that can be solved by an algorithm that can be solved in a finite number of steps

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