REVIEW TERMS Flashcards

Study Terms

1
Q
  1. ) What does RAM stand for?

2. ) What is the purpose of RAM model?

A
  1. ) What does RAM stand for? - Random Access Memory
  2. ) What is the purpose of RAM model?
    a. assumes that access to a word in memory requires 1 unit of time (generic single processor)
    b. we want a metric of computation that is machine independent
    c. support single constant time instruction
    d. cost is uniform for all simple instruction
    e. unlimited memory
    f. flat memory (no memory hierarchy)
    g. sequential execution - (no concurrency)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What criteria affect(s) the complexity of an algorithm?

A

What criteria affect(s) the complexity of an algorithm?

  • a complexity of an algorithm depends on
    a. size of input
    b. other characteristics of input, such as partially solved
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q
  1. Define worst case complexity
  2. Define average case complexity
  3. Define best case complexity
A
  1. Define worst case complexity
  • The maximum steps that the algorithm
    can take for ANY possible input
  1. Define average case complexity
    - The average of the running times of ALL of the possible inputs
  2. Define best case complexity
    - The minimum number of steps for any possible input
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Given LINEAR-SEARCH Algorithm

LINEAR-SEARCH (A, key)

1: i = 0 . c1
2: while i < n and A[i] != key do . c2
3: i + + . c3
4: end while
5: if i < n then . c5
6: return true . c6
7: else
8: return false . c8

What is the worst case and the best case complexity of Linear-Search?

A

What is the worst case and the best case complexity of Linear-Search?

Best case: if the key is the first element in the array.
T(n) = c1n + c2n + c5n + c6n

Summary: 
 >>Line 1  number of execution = 1 unit 
>>Line 2  number of execution = 1 unit
>>Line 5 number of execution = 1 unit
>>Line 6 number of execution = 1 unit

Worst case: key is not in the array
T(n) = c1n + k

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

What is order of growth?

What is Asymptotic complexity?

What is complexity?

A

What is order of growth?

> > How running time grows with input size

What is Asymptotic complexity?
» The running time for large inputs

What is complexity?
»is denoted/dominated by the highest order term in the
expression for running time … recall that unless explicitly stated
otherwise, we are concerned with the worst time analysis of an algorithm

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

If the complexity of algorithm A is of a higher order than the
complexity of algorithm B, what can we say about A and B?

A

If the complexity of algorithm A is of a higher order than the complexity of algorithm B, what can we say about A and B?

> > we say that B is more efficient than A

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

Show growth rates of the following:

O(1) < O(logn) < O(n) < O(nlogn) < O(n^2) < n^k where k is some constant > 2 < n!

A

Show growth rates of the following:

O(1) < O(logn) < O(n) < O(nlogn) < O(n^2)

O(1) - Constant time ...
• O(logn) - Logarithmic time ...
• O(n) - Linear time ...
• O(nlogn) linear times log(n) 
• O(n^2)  Quadratic time 
• O(n^k)  polynomial time
• O(2^n)  exponential
• O(n!) factorial
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is Asymptotic Efficiency?

Define bound?

A

What is Asymptotic Efficiency?

> > concerned with the running time of an
algorithm as the size of the input increases without bound

Define bound?

> > A measure of ”close”ness of one property to
another

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

What is Recurrence equation (recurrence)?

A

What is Recurrence equation (recurrence)?

> > the running time for a
divide-and-conquer algorithm on input of size n, represented in terms of
the running time of the “smaller” sub problems.

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

What is a BST : Binary Search Tree?

A

What is a BST : Binary Search Tree?

A Binary Search Tree (BST) is a tree in which all the nodes follow the below-mentioned properties −

The left sub-tree of a node has a key less than or equal to its parent node’s key.

The right sub-tree of a node has a key greater than to its parent node’s key.

Thus, BST divides all its sub-trees into two segments; the left sub-tree and the right sub-tree and can be defined as −

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

For an unbalance tree:

What is the cost for T(n) = T(n/4) + T(3/n4) + n

A

For an unbalance tree:

What is the cost for T(n) = T(n/4) + T(3/n4) + n

> > • Level 0 : n → cost: n
• Level 1 : (n/4) + (3n/4) → cost: n
• Level 2 : (n/16) +(3n/1)6 +(3n/16) +(9n/16) → cost: n

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

T(n) = 3T(n/4) + Θ(n^2)?

What is \theta (n^2) refer to?

A

T(n) = 3T(n/4) + Θ(n^2)?

What is \theta (n^2) refer to?

>> The amount of work done by “each” invocation of the algorithm/function needs n
2 work (times some constant) plus the work of all recursive calls.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is mathematical Induction?

A

What is mathematical Induction?

>> Mathematical induction proves that
we can climb as high as we like on
a ladder, by proving that we can
climb onto the bottom rung (the basis) and that from each rung we can
climb up to the next one (the step).
– Donald Knuth

> > if P(k) is true (called induction hypothesis), then P(k + 1) is true …
in other words, if the basis step and the inductive step are proven, then
P(n) is true for all natural numbers

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

What is the purpose of loop invariants?

Define loop invariant?

A

What is the purpose of loop invariants?

> > allow for assessing correctness of an algorithm

Define loop invariant?

> > A statement about an algorithm that remains valid throughout all iterations of the algorithm

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

What can be said about loop invariants for:

Initialization, Maintenance, and Termination

A

What can be said about loop invariants for:

Initialization, Maintenance, and Termination

Initialization : the “condition” is true BEFORE the first iteration of a for loop

Maintenance : the “condition” is true AFTER each iteration and is true BEFORE each next iteration of a for loop

Termination : the “condition” is true AFTER a for loop terminates, and provides useful information about the correctness of an algorithm

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

Q: What is the heap data structure?
Q: What are the heap data structure operations?
Q: What is the run-time analysis of a heap and its operations?

A

Q: What is the heap data structure?
» A Heap is a special Tree-based data structure in which the tree is a complete binary tree. Generally, Heaps can be of two types: Min or Max Heap

Q: What are the heap data structure operations?
• DeleteMax(A)
• Max-Heapify(A,i)
• Build-Max-Heap(A,n)
• Heapsort(A)
• Insert(A)
• DecreaseKey(A,i,key)
• IncreaseKey(A,i,key)
• PercolateDown(A,i)
• PercolateUp(A,i)

Q: What is the run-time analysis of a heap and its operations?

max-heapify : O(lgn)

17
Q

Define Probabilistic analysis.

A

Define Probabilistic analysis.

> > Probabilistic analysis is how we analyze the performance and run-time of
probabilistic algorithms. Deterministic algorithms are analyzed via
worst-case scenarios, and suitable for assessing Big-O, as well as Θ, and Ω.

18
Q

Define indicator variables.

A

Define indicator variables.

> > In order to analyze randomized algorithms, we use indicator variables.
Indicator variables permit “converting” between probabilities and
expectations.

19
Q

What is a hash function used for?

A

What is a hash function used for?

> > A hash function is used to inform where to index into the array
when looking for key k… start looking from that location