CS theorems

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

depth-first search (DFS)

*As if graph G was a maze of interconnected rooms and you were walking around in it --> you'd start from s and try the first edge leading out of it, to a node v. Then you'd follow the first edge leading out of v, and continue until you reach a "dead end" -- a node for which you had already explored all its neighbors; then you'd backtrack until you got to a node with an unexplored neighbor and resume from there. *It explores G as deeply as possible and only retreats when necessary

Stable Matching Problem

*Can you design a college admissions process, or a job recruiting process, that is self-enforcing? *involves the interplay between two different types of parties: companies (employers) and students (applicants); each applicant has a preference ordering on companies, and each company forms a preference ordering on its applicants. *Given a set of preferences among employers and applicants, can we assign applicants to employers so that for every employer E, and every applicant A who is not scheduled to work for E, at least one of the following two things is the case?: (i) E prefers every one of its accepted applicants to A; or (ii) A prefers her current situation over working for employer E. --> If this holds, the outcome is "stable": individual self-interest will prevent any applicant/employer deal from being made behind the scenes.

Breadth-First Search (BFS)

-start at s and explore outward from s in all possible directions, adding nodes one "layer" at a time *Start with s and include all nodes that are joined by an edge to s = add these to 1st layer of the search tree. *Then include all additional nodes that are joined by an edge to any node in the first layer = add these to 2nd layer of the search tree. *Continue until no new nodes are encountered.

factors that affect efficiency of algorithms

1) size of input = the number of the objects of particular interest; 2) primitive operations = operations whose number dominates the total number of operations

DAG

= "Directed Acyclic Graphs" = a directed graph that has no cycles; used to encode precedence relations or dependencies --> i.e. suppose we have a set of tasks label [1, 2, ..., n] that need to be performed and there are dependencies among them stipulating, for certain pairs i and j, that i must be performed before j. Then a node represents each task, and a directed edge (i,j) means the i must be done before j. The resulting graph G must be a DAG!

mutually reachable

= 2 nodes u and v in a directed graph are "mutually reachable" if there is a path from u to v and also a path from v to u (so a graph is strongly connected if every pair of nodes is mutually reachable)

worst-case running time

= a bound on the largest possible running time the algorithm could have over all inputs of a given size N

strongly connected graph

= a directed graph is "strongly connected" if, for every 2 nodes u and v, there is a path from u to v and a path from v to u

graph

= a discrete structure used to encore pairwise relationships among a group of objects; G = (V,E), where V = collection of all nodes or vertices in graph G, and E = collection of all edges in graph G

bipartite

= a graph where the node set V can be partitioned into sets X and Y in such a way that every edge has one end in X and the other end in Y; *imagine the nodes in set X are colored red, and the nodes in set Y are colored blue; a graph is bipartite if it is possible to color its nodes red and blue so that every edge has one red end and one blue end! = graph is "two-colorable"

stable matching S

= a matching S is stable IF (i) it is perfect, an (ii) there is no instability with respect to S.

perfect matching S'

= a matching with the property that each member of M and each member of W appears in EXACTLY ONE pair in S'

cycle

= a path v1, v2, ..., v(k-1), v(k) in which k>2, the first k-1 nodes are all distinct, and v1=v(k) -- the sequence of nodes "cycles back" to where it began

simple path

= a path where all its vertices are distinct from one another

queue

= a set from which we extract elements in FIFO (first-in, first-out) order: we select elements in the same order in which they were added

stack

= a set from which we extract elements in LIFO (last-in, first-out) order: each time we select an element, we choose the one that was added most recently

matching S

= a set of ordered pairs, each from M x W, with the property that each member of M and each member of W appears in AT MOST one pair in S

compatible

= a subset of requests is "compatible" if no two of them overlap in time

greedy algorithm

= an algorithm that builds up a solution in small steps, choosing a decision at each step myopically to optimize some underlying criterion

efficient algorithm

= an algorithm whose running time is bounded by a polynomial function of its input size *has the following properties: (1) Correct: it behaves as intended (2) Deterministic: for the same input, we receive the same output.

connected graph

= an undirected graph is "connected" if, for every pair of nodes u and v, there is a path from u to v

tree

= an undirected graph that is connected and does not contain a cycle

optimal set in interval scheduling

= compatible sets of maximum size

M x W

= denotes the set of all possible ordered pairs of the form (m,w), where m is an element of M and w is an element of W

topological ordering

= for a directed graph G, a topological ordering of G is an ordering of its nodes as v1, v2, ..., vn so that for every edge (vi, vj), we have i<j; all edges point "forward" in the ordering; this provides an order in which tasks can be safely performed; when we come to task vj, all the tasks that are required to precede it have already been done

interval scheduling

= goal is to accept as large a compatible subset as possible

stays ahead approach to greedy

= if one measures the greedy algorithm's progress in a step-by-step fashion, one sees that it does better than any other algorithm at each step; it then follows that it produces an optimal solution

instability with respect to S

= if there are 2 pairs (m,w) and (m',w') in S with the property that m prefers w' to w, and w' prefers m to m' -- (m,w') does not belong to S, but each of m and w' prefers the other to their partner in S

path

= in an undirected graph G = (V,E), it is a sequence P of nodes v1, v2, ... v(k-1), v(k) with the property that each consecutive pair v(i), v(i+1) is joined by an edge in G

exchange argument

= one considers any possible solution to the problem and gradually transforms it into the solution found by the greedy algorithm without hurting its quality

distance

= the minimum number of edges between two nodes u and v

degree(x)

= the number of adjacent nodes to x

height

= the number of edges in the longest path of a tree

1.6

Consider an execution of the G-S algorithm that returns a set of pairs S. The set S is a stable matching.

1.7

Every execution of the G-S algorithm results in the set S**, where S** is the set of pairs {(m, best(m)) : m is an element of M}

3.1

Every n-node tree has exactly n-1 edges.

3.6

For a given recursive call DFS(u), all nodes that are marked "Explored" between the invocation and end of this recursive call are descendants of u in T.

3.17

For any 2 nodes s and t in a directed graph, their strong components are either identical or disjoint.

3.8

For any 2 nodes s and t in a graph, their connected components are either identical or disjoint (having no elements in common).

3.3

For each j >= 1, Layer Lj produced by BFS consists of all nodes at distance exactly j from s. There is a path from s to t IFF t appears in some layer.

3.18

If G has a topological ordering, then G is a DAG.

3.20

If G is a DAG, then G has a topological ordering.

3.14

If a graph G is bipartite, then it cannot contain an odd cycle.

1.4

If m is free at some point in the execution of the algorithm, then there is a woman to whom he has not yet proposed.

3.16

If u and v are mutually reachable, and v and w are mutually reachable, then u and w are mutually reachable.

3.19

In every DAG G, there is a node v with no incoming edges.

1.8

In the stable matching S*, each woman is paired with her worst valid partner.

3.15

Let G be a connected graph, and let L1, L2, ... be the layers produced by BFS starting at node s. Then EXACTLY 1 of the following 2 things must hold: (1) There is no edge of G joining 2 nodes of the same layer. In this case, G is a bipartite graph in which the nodes in even-numbered layers can be colored red, and the nodes in odd-numbered layers can be colored blue. (2) There is an edge of G joining 2 nodes of the same layer. In this case, G contains an odd-length cycle, and so it cannot be bipartite.

3.2

Let G be an undirected graph on n nodes. Any 2 of the following statements implies the 3rd: (1) G is connected (2) G has no cycles (3) G has n-1 edges

3.4

Let T be a breadth-first search tree, let x and y be nodes in T belonging to layers Li and Lj respectively, and let (x,y) be an edge of G. Then i and j differ by AT MOST 1 (either on the same level or one level apart).

3.7

Let T be a depth-first search tree, let x and y be nodes in T, and let (x,y) be an edge of G that is not an edge of T. Then one of x or y is an ancestor of the other.

1.3

The G-S (Gale-Shapley) algorithm terminates after at most n^2 iterations of the While loop.

3.12

The above algorithm implements DFS, in the sense that it visits the nodes in exactly the same order as the recursive DFS procedure in the previous section (except that each adjacency list is processed in reverse order).

3.11

The above implementation of the BFS algorithm runs in time O(m+n) (i.e. linear in the input size), if the graph is given by the adjacency list representation.

3.13

The above implementation of the DFS algorithm runs in time O(m+n) (i.e., linear in the input size), if the graph is given by the adjacency list representation.

3.10

The adjacency matrix representation of a graph requires O(n^2) space, while the adjacency list representation requires only O(m+n) space.

1.2

The sequence of women to whom m proposes gets worse and worse (in terms of his preference list)

3.5

The set R produced at the end of the algorithm is precisely the connected component of G containing s.

1.5

The set S returned at termination is a perfect matching.

3.9

The sum of all nodes' degrees (nv) = 2m

1.1

w remains engaged from the point at which she receives her first proposal; and the sequence of partners to which she is engaged gets better and better (in terms of her preference list)


Kaugnay na mga set ng pag-aaral

People of the American Revolution

View Set

Darby Comprehensive Review Chapter 4 Head and Neck

View Set

SPAN 101 FINAlS pt. 1 (section 1-10)

View Set

BAO6 Power Tools (Intro to Robotics)

View Set