chapter 2 Flashcards

1
Q

what dose Analysis of algorithms refers to

A

determining how “good” an algorithm is, usually in
terms of running time and storage.

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

for what is algorithm analysis

A

allows you to make quantitative judgments about the value of one algorithm over another

allows you to predict whether the software will meet any efficiency constraints that exist.

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

T or F:

A

running time and memory are bounded resources

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

What is running time

A

How long an algorithm needs to produce the output.

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

The running time of an algorithm typically grows with…..

A

input size

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

Three estimated running time

A

best,
average and
worst

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

how to analyze an algorithm

A

in onw of these two ways

1-expermintal study (real code, some typical input test,depends on HW/SW)
2-theoritcal study (all pssiable inputs, indepndent from HW/SW)

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

what is expiermental study in algorithm analysis steps

A

1 implement the algorithm with code
2 run program diffrent possible input
3 mark up running time with functions in code like clock
4 plot the result

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

Limitations on expiermental study in algorithm analysis

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

some traits of theortical analysis

A

**Uses a high-level description of the algorithm instead
of an implementation. **

**Represents running time based on the number of
primitive operations or steps executed. **

**Characterizes running time as a function of the input
size, n. **

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

what is primtave operations and give some example of it

A

**basic computations performed by an algorithm
**
Examples:
Evaluating an expression
Assigning a value to a variable
Indexing into an array
Calling a method
Returning from a method

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

Indexing into an array
Calling a method are examples of

A

Primitive operations

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

i=1
loop (i<=1000)
application code
i=i+1
end loop

A

f(n)=1000

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

i=1
loop (i<n)
application code
i=i x 2
end loop

A

f(n)= log2 n

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

i=1
loop (i<=n)
j=1
loop (j<=n)
application code
j= j +1
end loop
i=i + 1
end loop

A

f(n)= n2

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

i=1
loop (i<=n)
j=1
loop (j<=n)
application code
j= j *2
end loop
i=i + 1
end loop

A

f(n)= n log n

16
Q

i=n
loop (i>=1)
application code
i=i / 10
end loop

A

f(n)= log10 n

17
Q

for (i = 0; i < n; i++)
sum++;
for (j = 1; j <= n; j*=2)
sum++;

A

f(n)= n + log n

18
Q

i=1
loop (i<=n)
j=1
loop (j<=i)
application code
j= j + 1
end loop
i=i + 1
end loop

A

f(n)=n [(n+1)/2]

19
Q

for (i = 0; i < n; i++)
for (j = 0; j < m; j++)
if (a[i][j] == x) return 1 ;
return -1;

A

f(n)=n.m

20
Q

sum = 0;
for( i = 0; i < n; i++)
for( j = 0; j < n * n; j++)
sum++;

A

f(n)= n3

21
Q

assume we have an if statment with each part of the statment having diffrent big o size(eg. if C n times else S stop) how do we determine the big o of this exprssion

A

whatever is bigger with set it as the big o

22
Q
A