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
Q

Defensive Programming

A

Write specifications for functions
Modularity Programs
Check conditions on inputs/outputs

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

Unit Testing

A

Validate each piece of program. Testing each function separately.

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

Regression Testing

A

Add test for bugs as you find them. Can reintroduce errors that were previously fixed

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

Integration Testing

A

Does the overall problem work?

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

Black Box Testing

A

Explore paths through specification; through docstring

30
Q

Glass Box Testing

A

Explore paths through code. Path complete if every potential path through code is tested.

31
Q

Overt Bugs

A

Bug with obvious manifestation

32
Q

Covert Bugs

A

Not obvious; codes returns a value, but it is incorrect.

33
Q

Raising Exceptions

A

Try:
Code
Except
Code such as raise Exception(“desc”)

34
Q

Object

A

Every object has;
A type
An internal representation of data
Set of procedures for interaction

35
Q

Defining a Python Type

A

class ClassName(object):

36
Q

Attributes

A

Data and procedures belonging to the class.

37
Q

Big Oh Notation

A

Measures an upper bound in the asymptotic growth often called order of growth.

38
Q

Complexity Classes Order

A

O(1), O(log n), O(n), O(nlog n), O(n^c), O(c^n)

39
Q

Searching

A

Search method for finding an item or group of items with specific properties within a collection of items

40
Q

Linear Search

A

Brute force, list does not need to be sorted

41
Q

Bisection Search

A

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
Q

Monkey Sort or Bogo Sort

A

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
Q

Bubble Sort

A

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
Q

Selection Sort

A

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
Q

Merge Sort

A

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
Q

Optimization Models

A

An objective that is to be maximized or minimized using a set of constraints (possibly empty) that must be honored.

47
Q

Knapsack Problem Formalized

A

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
Q

Greedy Algorithm

A

Practical alternative. While knapsack not full, put “best” available item in knapsack. Finds local optimizations.

49
Q

Search Tree

A

Built top down starting with root.

50
Q

Dynamic Programming

A

Trade time for space, so algorithms run quicker.

51
Q

When does dynamic programming work?

A

Optimal substructure and/or overlapping sub problems.

52
Q

Optimal Substructure

A

A globally optimal solution can be found by combining optimal solutions to local subproblems.
Fib(x) and merge sort.

53
Q

Overlapping Subproblems

A

Finding an optimal solution involves solving the same problem multiple times.
Fib(x)

54
Q

Graph

A

Set of nodes (verifies) that might have associated proprieties and set of edges (arcs) each consisting of a nice pair.

55
Q

Undirected Graph

A

Two way street, like being friends on Facebook.

56
Q

Directed graph

A

Source (parent) and destination (child) node.

57
Q

Depth-first Search

A

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
Q

Breadth-first Search

A

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
Q

Stochastic Process

A

An ongoing process where the next state might depend on both the previous state and some random element.

60
Q

Copenhagen Doctrine of Causal Nondeterminism

A

At its most fundamental level, the behavior of the physical world cannot be predicted.

Let by Bohr and Heisenberg

61
Q

Random Walk

A

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
Q

Law of Large Numbers (Bernoulli’s Law)

A

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
Q

Probability Density Function

A

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
Q

Central Limit Theorem

A

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
Q

Monte Carlo Simulation

A

Method of estimating the value of an unknown quantity using randomness and the principles of inferential statistics.

66
Q

Buffon-Laplace Estimate of Pi

A

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
Q

Simple Random Sampling

A

Each members of the population has an equal change of being chosen. (Not always appropriate).

68
Q

Stratified Sampling

A

Partition population into homogeneous subgroups and take a random sample from each subgroup.

69
Q

R Squared

A

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
Q

Cross-Validation

A

Generate model using one dataset, then test on another.

71
Q

Leave One Out Testing for Cross-Validation

A

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
Q

K Fold Testing for Cross-Validation

A

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.