Computer Science Flashcards

1
Q

What are the types of knowledge?

A

(1) Declarative, (2) Imperative

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

Algorithm

A

Finite list of instructions that describe a computation that when executed on a provided set of inputs will proceed through a set of well-defined states and eventually produce an output

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

Fixed program computer

A

Solves a specific problem

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

Store program computer

A

Stores/manipulates a sequence of instructions

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

Church-turing thesis

A

If a function is computable, then a Turing Machine can be programmed to compute it.

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

Turing completeness

A

A programming language is said to be Turing complete if it can be used to simulate a universal Turing machine (All modern programming languages)

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

What are the components of each programming language?

A

(1) Primitive constructs—“words”, literals, infix operators
(2) Syntax—defines which strings of characters are well-formed ( )
(4) Static Semantics–defines which syntactically valid strings have meaning (3.2/’abc’)
(6) Semantics–what does it mean?

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

Constant-time programs

A

A program for which the maximum running time is said to run in constant time. There exists a constant k such that the program is guaranteed to take no more than k steps to run. Running time does not grow with the size of the input. Limited.

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

Decrementing function

A

A function (typically for describing a loop) that:

(1) maps a set of program variables into an integer (ans**2-|x|)
(2) When the loop is entered, its value is nonnegative
(3) Loop terminates when value is <= 0
(4) Value decreased every time through the loop

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

What is the decrementing function for the following loop?

x = 8
ans = 0
while(ans**3<abs(x)):
    print ans
    ans = ans + 1
A

ans3 < abs(x)
0 < abs(x)-ans
3

The decrementing function is abs(x) - ans**3

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

Exhaustive enumeration

A

“Guess and check”. Enumerate all possibilities until we get to the right answer/exhaust all possibilities.

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

Bisection search

A

Searches for answer based on approximations. Takes advantage of the fact that numbers are ordered.

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

Newton’s method for roots

A

For a polynomial p(x) = x**2 + x + c, the root r is when p(r) = 0.

If a guess is an approximation of this root, then:

guess - p(guess)/p’(guess) is a better approximation of the root.

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

What number is represented in the binary number 101?

A

1(22) + 0(21) + 1(2**0) = 4 + 1 = 5

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