MIT 600 Flashcards

1
Q

Algorithm

A

Sequence of steps

Flow of control process that specifies when each step is executed

A means of determining when to stop

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

Turning Complete

A

Anything computable in one language is computable in any other programming language.

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

Syntax

A

Determines if code is legal.

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

Static Semantics

A

Determines whether code has meaning.

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

Semantics

A

Assigns meaning to a legal sentence.

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

Python Types

A

Int-integer
Float-real numbers
Bool-boolean, True + False
NoneType - special, value of None.

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

Casting

A

Type conversion, i.e.
Changing from Int type to Float.

Float(5)–5.0

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

Branch Programs

A

Simplest is a condition. A test, a block of code to execute if true, and optional block to execute if false.

Is a linear program, runs in constant time.

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

String

A

Letters, special characters, spaces, digits encompass in single or double quotes.

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

Concatenation

A

Adding string together, i.e.

AB+CD=ABCD

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

While Loops

A

If condition if true, run code, check condition, repeat until false

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

Bisection Search -Sqrt Example

A

Know square root of x is between 1 and x. Rather than starting at 1, start at a number in the middle.
If not close enough, if g**2>x, g is too big.

Throws away half if possible guesses each iteration

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

Bisection Search Big Oh

A

Logarithmic time, log2N steps

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

Implications of Binary

A

If there’s is not an integer p such that x*(2**p) is whole, then the internal representation is an approximation.

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

Newton-Raphson

A

Approximation to root, g is the approximation;

g-p(g)/p1(g) is a better approximation where p1 is the derivative.

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

Abstraction

A

Suppress details of method to compute something from the use of that computation

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

Decomposition

A

Break problem into different, self-contained pieces

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

Function

A

Reusable piece or chunk of code, not run in a program until called or invoked.

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

Recursion

A

Divide and conquer or decrease and conquer. Technique where a function calls itself.

Flow passes back to previous scope once the function call returns the value.

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

Module

A

A .py file containing of collection of python definitions and statements. Call using the import keyword.

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

Tuples

A

Ordered sequence of elements
Immutable, cannot change element values
Represented with parentheses
Iteratable and can be sliced

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

List

A

Order sequence of elements
Denotes by square brackets
Mutable
Iterable, can be indexed

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

List Operations

A
L.append()
L.extend()
del(L[index])
L.pop() remove and return the element
L.remove(element) removes first occurrence
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

Memoization

A

optimization technique used primarily to speed up computer programs by storing the results of expensive function calls and returning the cached result when the same inputs occur again.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Defensive Programming
Write specifications for functions Modularity Programs Check conditions on inputs/outputs
26
Unit Testing
Validate each piece of program. Testing each function separately.
27
Regression Testing
Add test for bugs as you find them. Can reintroduce errors that were previously fixed
28
Integration Testing
Does the overall problem work?
29
Black Box Testing
Explore paths through specification; through docstring
30
Glass Box Testing
Explore paths through code. Path complete if every potential path through code is tested.
31
Overt Bugs
Bug with obvious manifestation
32
Covert Bugs
Not obvious; codes returns a value, but it is incorrect.
33
Raising Exceptions
Try: Code Except Code such as raise Exception("desc")
34
Object
Every object has; A type An internal representation of data Set of procedures for interaction
35
Defining a Python Type
class ClassName(object):
36
Attributes
Data and procedures belonging to the class.
37
Big Oh Notation
Measures an upper bound in the asymptotic growth often called order of growth.
38
Complexity Classes Order
O(1), O(log n), O(n), O(nlog n), O(n^c), O(c^n)
39
Searching
Search method for finding an item or group of items with specific properties within a collection of items
40
Linear Search
Brute force, list does not need to be sorted
41
Bisection Search
List must be sorted. Looks for item at the center, if it doesn't find it, checks if the center is too low or too high and searches the corresponding half.
42
Monkey Sort or Bogo Sort
Stupid sort, essentially sorting a deck of cards by throwing it in the air, picking it up and hoping it's sorted. Repeat if not.
43
Bubble Sort
Compare consecutive pair of elements, swap elements so that smaller is first, when reaches the end of list, start again. Stop when no more swaps have been made.
44
Selection Sort
Extract minimum element, swap with element at index 0. Extract minimum element from remaining sub list and swap with element at index 1. Keep left portion sorted.
45
Merge Sort
Divide and conquer approach. If list is of length 0 or 1, already sorted. Split list in two two lists and sort/keep splitting each list. Merge sorted lists; Look at first element of each, move smaller to end of result list. When one list is empty just copy the rest of the other list to the end of result. BEST MOST EFFICIENT SORT
46
Optimization Models
An objective that is to be maximized or minimized using a set of constraints (possibly empty) that must be honored.
47
Knapsack Problem Formalized
Find a V that maximizes; The sum from i to n-1 of V[i] *I[i].value Subject to constraints that; The sum from i to n-1 of V[i] *I[i].weight < w
48
Greedy Algorithm
Practical alternative. While knapsack not full, put "best" available item in knapsack. Finds local optimizations.
49
Search Tree
Built top down starting with root.
50
Dynamic Programming
Trade time for space, so algorithms run quicker.
51
When does dynamic programming work?
Optimal substructure and/or overlapping sub problems.
52
Optimal Substructure
A globally optimal solution can be found by combining optimal solutions to local subproblems. Fib(x) and merge sort.
53
Overlapping Subproblems
Finding an optimal solution involves solving the same problem multiple times. Fib(x)
54
Graph
Set of nodes (verifies) that might have associated proprieties and set of edges (arcs) each consisting of a nice pair.
55
Undirected Graph
Two way street, like being friends on Facebook.
56
Directed graph
Source (parent) and destination (child) node.
57
Depth-first Search
Must keep track of what nodes have been visited. Search down an entire node path first to try and find the destination solution. Lots of back tracking.
58
Breadth-first Search
Explore all paths with n hops before exploring any path with more than n paths. Cannot be easily modified for weighted shortest path the way DFS can.
59
Stochastic Process
An ongoing process where the next state might depend on both the previous state and some random element.
60
Copenhagen Doctrine of Causal Nondeterminism
At its most fundamental level, the behavior of the physical world cannot be predicted. Let by Bohr and Heisenberg
61
Random Walk
A mathematical object, known as a stochastic or random process, that describes a path that consists of a succession of random steps on some mathematical space. Can explain the observed behaviors of many processes in these fields, and thus serve as a fundamental model for the recorded stochastic activity.
62
Law of Large Numbers (Bernoulli's Law)
In repeated independent tests with the same actual probability p of a particular outcome in each test, the chance that the fraction of times that outcome occurs differs from p converges to zero as the number of trials approach infinity.
63
Probability Density Function
Probability of a random variable lying between two values. Defines a curve where the values on the x-axis lie between a max and min of the value. Area under the curve of two points is the probability of example falling within that range.
64
Central Limit Theorem
Given a sufficiently large sample; The mean of the samples in a set of samples (the sample means) will be approximately normally distributed. This normal distribution will have a mean close to the population mean. The variance of the sample means will be close to the variance of the population divided by the sample size.
65
Monte Carlo Simulation
Method of estimating the value of an unknown quantity using randomness and the principles of inferential statistics.
66
Buffon-Laplace Estimate of Pi
Circle in a 2x2 square, drop needles at random, because circle's area is equal to pi, pi equals the area of the square times the ratio of needles in the circle to the needles in the square.
67
Simple Random Sampling
Each members of the population has an equal change of being chosen. (Not always appropriate).
68
Stratified Sampling
Partition population into homogeneous subgroups and take a random sample from each subgroup.
69
R Squared
Compared estimation errors to variance of the original values. Intended to capture the proportion of variability in the data that is explained by the model. R^2 = 1, model explains all.
70
Cross-Validation
Generate model using one dataset, then test on another.
71
Leave One Out Testing for Cross-Validation
Leave out one example, train model on others and then test on left out example. Repeat until every example has been the left out one.
72
K Fold Testing for Cross-Validation
Data partitioned into K equal size sets. Model trained on K-1 sets and tested in the remaining. Repeat until each of the K sets has been left out. Average the results.