Part 4 Flashcards

1
Q

What is big O notation?

A

A way of representing the worst case run time of an algorithm

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

O(n) indicates that the algorithm time

A

increases proportionally to the number of elements

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

What is the value of

k X T1(n)

where k is a positive constant

A

O(f(n))

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

the value of

T1(n) + T2(n)

is

A

O(max(f(n), g(n)))

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

the value of

T1(n) X T2(n)

is

A

O(f(n) X g(n))

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

an exponential algorithm has time complexity

A

O(2n)

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

To specify a lower bound, rather than an upper bound, Big __ notation is used

A

Ω

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

Why can very precise mathematical calculations of running time not be made?

A

It is impossible to know what will be generated by the compiler

Can only make guesses

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

T(n) is approximately proportional to f(n) if there exist some constants C and D such that

A

T(n) >= Cxf(n) and T(n)<=Dxf(n)

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

Why does the formal definition of a meaning for “approximately proportional to” ignore small values of n?

A

Lots of algorithms have running time approximately proportional to log2(n)

In this case, It is impossible to find a value for D which works when n is 1 because log2(1) is 0

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

T(n) is said to be O(f(n)) if there exist constants C and N such that

A

T(n) <= Cxf(n) for all values of n greater than or equal to N

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

It is impossible to produce a general-purpose sorting algorithm whose average-case running time is better than

A

O(nlog2(n))

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

What is the time complexity of simple expressions and assignments in Java?

A

O(1)

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

What is the time complexity of

for (int i = 1; i < n; i++)

for (int j = 0; j < i; j++)

sum = sum+j;

A

O(n2)

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