graphs Flashcards
types of problems
Decision problems: trying to decide whether a statement is true or false.
They have either yes or no as the solution.
Optimization problems: trying to find the solution with the best possible score according to some scoring scheme.
what are maxmization and minmisation problems
Maximization problems: trying to maximize a certain score.
Minimization problems: trying to minimize a cost function.
what is Optimization:
choosing the best element from a set of alternatives
For an optimization problem you want to find, ………, but the ………..
For an optimization problem you want to find, not just a solution, but the best solution.
what is optimization algorithm
is a numerical method or algorithm for finding a value x such that f(x) is as small (or as large) as possible, for a given function f, possibly with some constraints on x.
what types of algorthims we use For solving Optimization problems:
Greedy algorithm
Dynamic programming algorithm
Branch and bound algorithm(BFS)
what is the greedy algorthim way of solving a problem
give an example
by always making the choice that looks the best at the moment
-it makes locally optimal choices in hope that it will lead to glopal optimal solution
T or F: Greedy algorithms always yield optimal solutions
F
Greedy algorithms do not always yield optimal solutions, but for many problems they do.
Algorithms for optimization problems typically work as
a sequence of steps, with a set of choices at each step.
Examples of Greedy Algorithms :
Minimum-spanning-tree algorithms
Shortest path problems.
Travelling salesman problem.
The knapsack problem (items are divisible).
Task scheduling problem.
Huffman Coding.
T or F: The greedy method is quite powerful and works well for a wide range of problems.
T
what is a tree
connected undiractional graph with no cycle
problems like finding smallest , logest largest are …… problems and ……. algorthims can be used to solve them
problems like finding smallest , logest largest are optimazation problems and greedy algorthim algorthims can be used to solve them
what is spanning tree
A Spanning Tree of a graph G is a subgraph of G that is a tree and contains all the vertices of G
what are the spanning tree properties
1-a spanning tree of n vertix has n-1 edges
2-connected in all vertices
3-has no cycle
Minimum Spanning Trees, why?
To make multiple pins in an electronic circuit electrically equivalent, they are connected using wires. If there are ( n ) pins, ( n-1 ) wires are needed to connect all pins. The optimal arrangement is the one that uses the least amount of wire, as it is generally preferred to minimize the total wire length.
why we need MST in computer networks and shipping/airlines
Computer Networks
To find how to connect a set of computers using the minimum amount of wire.
Shipping/Airplane Lines
To find the fastest way between locations
what kind of approach are Kruskal’s algorithm
Prim’s algorithm
greedy approach/ staregy
prim and kruksal are …… methods that ……..
greedy strategy is captured by the following generic method, which grows the minimum spanning tree one edge at a time
why is kruksal qualifies as a greedy algorithm
each step it adds to the forest an edge of least possible weight.(choosing the best soultion ATM)
how kruksal algorthim avoid violating MST rules
If it were to form a cycle, it would simply link two nodes that were already part of a single connected tree, so that this edge would not be needed (REGECTED)
a safe edge in kruksal; algorthim is
always a least-weight (cheapest) edge in the graph that connects two distinct components (trees).
Without vilating MST
a safe edge is a
edgde that we add to the graph witout violating MST rules
Steps of kruksal algorithm:
intialze empty set A={};
create set of trees for all vertiexes in graph
sort all edges in non decresing order
for each edge (u,v) examine wether endpoint vertix belong in the same tree
-if same then edge cant be added and should be discarded
-if no edge belong to diffrent tree then add it to the tree