DesignAnalysis Algorithms COMP 4030
University of Memphis
Popular in Course
Popular in ComputerScienence
This 24 page Class Notes was uploaded by Dr. Marina Pollich on Friday October 23, 2015. The Class Notes belongs to COMP 4030 at University of Memphis taught by Staff in Fall. Since its upload, it has received 22 views. For similar materials see /class/228402/comp-4030-university-of-memphis in ComputerScienence at University of Memphis.
Reviews for DesignAnalysis Algorithms
Report this Material
What is Karma?
Karma is the currency of StudySoup.
You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!
Date Created: 10/23/15
COMP 46030 Introduction to Algorithms Elementary Graph Algorithms I February 27 2006 Outline 0 Graph definition 0 Graph representation 0 Search a graph Breadthfirst search BFS Depthfirst search DFS o textbook chapter 22 Representation Representation adjacency list 39 E w 9 0 r LLH K lll I 39 1 3 4 Space Time quot5 tr 1 HID 010 101 pe 3 1 ID 1 0 0 1 i U 1 l 1 3 II 1 D 11 CI 4 D 1 I D 1 5 i 1 D 1 CI Representation adjacency matrix Breadthfirst search BFSIIZV E 5 for each H E V Elm du m Coloruwhite If 1 U Q a 3139 EEQLTEUE j Q 5 TJ while Q gi E Nu u 1 DEQUEUEfQIa ll each L E Ad u In itquot 11 Ex Colorvwhite them du zfiu 1 C010rVgray EHQ LTELTE39E 9 u j C010rublack Breadthfirst search o BFS computes the shortest path distance COMP 46030 In oduc ontoMgo uns NPcompleteness I Ap 122006 rP 2 NP Outline o P NP NP C o NP C problems 0 How to solve NP C problems 0 goal definitions rudiments of the theory of NP completeness familiar with NPC class of problems P 0 Problems that are solvable in polynomial time 0 Examples 0 Encoding of a problem 0 Tractable If the current best algorithm has a running time of nA999 More efficient algorithms often follow For many reasonable models of computation a problem that can be solved in polynomial time in one model can be solved in polynomial in another Closed under addition multiplication composition NP 0 Problems that are verifiable in polynomial time 0 Examples 0 P NP NPcomplete 0 Problems that are In NP As hard as any problem in NP o If any NPC problem can be solved in polynomial time then every problem in NP has a polynomial time algorithm Easy and hard problems o Shortest path Find a shortest path between two vertices o Longest path Find a longest simple path between two vertices simple path all vertices in the path are distinct Easy and hard problems O Euler tour of a connected directed graph G A cycle that traverses each edge of G exactly once 0 Hamiltonian cycle ofa directed graph G A cycle that traverses each node of G exactly once Easy and hard problems o k CNF satisfiability A of V of exactly k literals Boolean variables or their negation o 2 CNF satisfiability o 3 CNF satisfiability Optimization problem vs decision problem o Shortest path Optimization Find a shortest path between two vertices uv Decision Given two vertices uv and an integer k whether a path exists from u to v consisting of at most k edges 0 Which one is harder Optimization problem vs decision problem 0 Traveling salesman problem TSP complete weighted graph G Optimization Find a minimumweight Hamiltonian cycle Decision Given a number k is there a Hamiltonian cycle with total weight at most k ngO NPcomplete problems 0 SAT satisfiability of boolean formulas o 3SAT o Hamiltonian cycle 0 TSP Minimum weight Hamiltonian cycle NPcomplete problems o Clique Clique in an undirected graph G complete subgraph of G Optimization find a clique of maximum size in G Decision decide if a clique of size k exists in G NPcomplete problems 0 Graph coloring Color vertices st adjacent vertices are not assigned to the same color Optimization determine the smallest number of colors needed to color G Decision decide if there is a coloring of G using at most k colors Applications 0 Scheduling problems NPcomplete problems o Knapsack Given a knapsack of capacity C and n objects with size slsn and profits p1pn Optimization find the largest total profit of any subset of the objects that fits in the knapsack and find a subset that achieves the max profit Decision decide if there is a subset of the objects that fits in the knapsack and has total profit at least k NPcomplete problems o Bin packing Given unlimited number of bins each of capacity 1 and n objects with size slsn Optimization determine the smallest number of bins into which the objects can be packed and find an optimal packing Decision does the objects fit in k bins Applications 0 Packing data in memories 0 Product to be cut from large standard sized pieces How to solve NPcomplete problems 0 Small input size okay 0 There may still be significant difference in the complexity of the extra polynomial algorithms develop the most efficient one possible 0 Use average rather than worst case behavior 0 Special input 0 Approximate algorithms
Are you sure you want to buy this material for
You're already Subscribed!
Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'