ITA - Week 3 Flashcards

1
Q

What are the approaches to analyse Time Complexity

A

Theoretical Analysis and Empirical Analysis

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

What is Theoretical Analysis

A

Study the number of times the algorithm performs some basic operations

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

What is Empirical Analysis

A

Code and run the algorithm on a computer for some inputs and measure how long it takes

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

What are the disadvantages of empirical analysis

A

Depends on speed of computer
Wastes time to code solution if algorithm is slow
Can’t try all inputs

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

How is efficiency measured

A

Basic operations and input size

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

How is the size of an input determined for a list input

A

The number of elements in the list

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

What is log2^x

A

x

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

What will log n refer to

A

log base2 n

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

log2(x*y) = ?

A

log2 x + log2 y

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

log2(x/y) = ?

A

log2 x - log2 y

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

log2(x^y) = ?

A

y * log2 x

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

What is A for a given algorithm

A

Worst case efficiency - Max running time
Best case - Min running time
Average case - Avg running time

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

The average case is the average of the best and worst case. True or False?

A

False

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

When is binary searching used instead of sequential searching

A

When a list is pre-sorted, as it is more efficient

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

What is the idea of a binary search

A

Compare k with middle element

If k is smaller than the middle, focus only of the first half and vice versa

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

Important functions

A

1 - constant
loga n - logarithmic
n, n^2… - polynomial
2^n - exponential

17
Q

What is Big-O notation

A

A way of comparing functions that ignores constant factors and small input sizes

18
Q

What is f(n) = O(g(n)) read as

A

f(n) is of order g(n)

19
Q

Big-O notation approximations

A

2n & n
n & n+1
n^2 +n & n^2

20
Q

Big-O hierarchy (lowest to highest)

A

log n < log^2 n < sqrt(n) < n < nlog n < n^2 < 2^n

21
Q

Big-O formal definition

A

f(n) exists in O(g(n)) if there exists constants c>0 and n0>0, such that f(n) eqg c . g(n) for all n>n0

22
Q

eqg meaning

A

Equal to or greater than