Big O Flashcards

1
Q

How can an algorithm be classed as efficient?

A

-no unnecessary steps
-same outcome but with minimum processing requirements
-shortest execution time

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

Define Big O notation

A

A mathematical notation used to describe how well an algorithm will perform as it is given increasingly larger datasets

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

Define efficiency

A

The ratio between the work an algorithm produces and its speed or memory requirements.

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

What do time requirements denote?

A

The time taken to complete the task

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

What do space requirements denote?

A

The amount of memory taken to complete a task

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

What can the time parameter be based off in a time measure function?

A

Number of memory accesses, number of comparisons, number of loops etc.
Sometimes refers to the real time taken to execute, run time

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

What does the parameter of the space measure function depend on?

A

Whether additional memory is used to store inputs for processing

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

List the factors that can determine efficiency of an algorithm:

A

-Human coding time
-time complexity
-space complexity

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

What factors are used to measure human coding time?

A

-time taken to develop a program
-time taken to maintain a program

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

What main factor effects human coding time?

A

Readability of the program

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

Define refactoring

A

Code is restructured without changing its purpose and behaviour to make it more clear, readable and efficient.

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

Describe the meaning of permutations

A

The number of ways of arranging objects

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

What is the formula for calculating the number of permutations?

A

p = n^r, where n is the number of choices we have, and r is the number of times a choice is made.

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

Describe the purpose of big O notation

A

-Big O notation is used to describe how the time requirements of an algorithm grow in relation to the number of items being processed. (worst case scenario)
-n refers to the number of items

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

List the types and their notations:

A

Constant: O(1)
Linear: O(n)
Logarithmic: O(log n)
Quadratic: O(n^2)
n Log n: O(n log n)
Cubic: O(n^3)
Exponential: O(2^n)

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

Give an example of an algorithm with a logarithmic time complexity

A

Binary search
Binary tree search

17
Q

Give an example of an algorithm with a linear complexity?

A

Linear search

18
Q

Describe a constant complexity

A

An algorithm that executes in the same time no matter the size of a dataset.

19
Q

Give an example of an algorithm with a polynomial complexity

A

Bubble sort ( because of nested loop, O(n^2) for one nested loop etc)

20
Q

Give an example of an algorithm with an exponential complexity

A

Travelling salesman problem
Permutations calculation

21
Q

Define tractable problems

A

Problems that can be solved in a polynomial time or less- solveable in a realistic amount of time

22
Q

Define intractable problems

A

Theoretically solveable problems, but cannot be solved in a realistic amount of time, take longer than a polynomial time to solve, O(n!) or O(2^n)

23
Q

Define heuristic algorithms

A

Provide an approximate, rule of thumb, but not exact solution to algorithms that are not time efficient to solve