Introduction Flashcards

1
Q

What does a problem p specify?

A

Given an input, what should be the output?

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

What is each allowed input to the problem called?

A

An instance

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

What is: an algorithm for problem P?

A

A step-by-step prodecure that, when given any instance I for problem P, gives the correct output in a finite amount of time

To describe an algorithm, we must provide a clear, unambiguous sequence of instructions. Anybody should be able to implement it without our help.

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

For the attached problem P:

What is an example of an instance of problem P?

What would the correct output be of that instance?

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

Design an algorithm for the attached example, adding two binary numbers.

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

What are 3 types of questions we often ask about an algorithm?

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

What is a model of computation?

Why is it important?

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

In RAM word model, how is data stored in the machine

A

Data is stored in the machine as word

Each word consists of u binary digits (bits)

(for example u = 32 or u = 64)

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

In the RAM word model what does each word represent?

A

Each word represents an integer. The possible values are called the universe u

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

In the universe U, using standard encoding for signed integers, the range of each word U =?

A

U = {-2u-1,…,2u-1-1}

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

In the RAM word model, what can we stored using O(1) words?

A

Any int, long, float, double can be stored using 0(1) words

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

How much time does it take to read or write any word in the RAM word model?

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

What is a primitive operation?

A

A primitive operation is an instruction that is assumed to take one “CPU step” (i.e., O(1) time, independent on word size u)

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

What are the primitive operations in the RAM word model?

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

What are examples of complicated arithmetic operations that are non-primitive

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

What are the possible measures of an algorithms efficiency?

17
Q

In general, how do we express the cost of an algorithm in terms of the input size?

18
Q

If one line of code consists of a “small numer” of primitive opertions, let’s call that _______

19
Q

Count the steps of the two following operations

int x = 2;

int y = 5;

int z = x + y;
z += 10;

vs

int z = 10*(2+5);

20
Q

In general, how do you calculate the number of steps in a loop?

21
Q

What is the running time of the following? (using summation notation)

22
Q

What is the running time of the following (in summation)?

23
Q

What is the running time in terms of someFunction?

24
Q

How do we calcylate the number of steps if the code contains conditional statements?

25
26
What is the run time?
27
28
What is the run time?
29
30
What is the summary of Asymptotic notation?
31
Describe how Big-Oh represents an upper bound, but not in an exact way
32
What should you write, instead of f(n) = O(g(n))
f(n) € O(g(n))
33