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?

A
17
Q

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

A
18
Q

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

A
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);

A
20
Q

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

A
21
Q

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

A
22
Q

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

A
23
Q

What is the running time in terms of someFunction?

A
24
Q

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

A
25
Q
A
26
Q

What is the run time?

A
27
Q
A
28
Q

What is the run time?

A
29
Q
A
30
Q

What is the summary of Asymptotic notation?

A
31
Q

Describe how Big-Oh represents an upper bound, but not in an exact way

A
32
Q

What should you write, instead of f(n) = O(g(n))

A

f(n) € O(g(n))

33
Q
A