Graph Search and Analysis Flashcards
Graph Search
Many graph algorthms use the same basic framework to navigate through a graph. We will call this algorithm: Graph Search
Shows which vertices can be retrivable from a certain vertex
Can be undirected or direct graph
Graph Search Algorithm
Instance: a graph G(V,E)
Instance: Starting Vertex s
Output: a list of all vertices reachable from s by a directed path in G
Big-O Notation
f(n) = O(g(n))
if f(n) = O(g(n)) then for a constant C, f(n) is strictly less than or equal to C(g(n))
Big OMEGA Notatio
f(n) = OMEGA(g(n))
if f(n) = OMEGA (g(n)) then g(n) = O(f(n)) where for a constant C, g(n) is strictly less than or equal to C(f(n))
Big-THETA Notation
f(n) = THETA(g(n))
if f(n) = THETA (g(n)) then
Factoring
Given a number N, express it as a product of its prime factors
Primality
Given a number N, determine whether it is a prime.
Different ways of understanding log N
- log N is the power to which you need to raise 2 in order ot obtain N
- The number of times you need to divide by 2 or halve N to get down to 1.
- It is the number of bits in the binary representation of N
- It is the depth of the complete binary tree with N Nodes
- It is the sum 1 + 1/2 + 1/3 +….. + 1/N to within a constant factor
When answering most questions in this class remember that …
the answer should be expressed as a function of the size of the input.
We are constantly wondering “if there is anything better”
In terms of how to improve the runtime of the algorithm
It is often useful to remember that while for small values of n studying algorithms seems trivial but we are interested in how theese algorithms do for large values of n
By studying in detail at the level of the elementary operations on the indiviudal bits, it can uncover how the hardware, transtiors and wires, are manipulated for the implemntation of the algorithm.
Bit shifting (padding a 0 to the right) is a simple way of multiplying the value by the bast.
By bit shifting binary, we double or multiply by 2 the current value of the binary sequence.
Questions to ask about any algorithm
IS this algorithm correct?
How long does the algorithm take?
Can we do better?
Modular Arithmetic
System for working with restricted ranges of integers
x modulo N is the remainder when x is divided by N, or x =qN + r, 0 =< r less than N, then x modulo N is equal to r.
Equivalence classes
For example, three equivalence classes of modulo 3 any member of an equivalence class is substitutable for any other; when the numbers 5 and 11 are no different. 0 class, 1 class, and 2 class are equivalent to the next class of remainders that are 0 , 1, and 2