Lecture 7 Jianjun Hu Department of Computer Science and Engineering University of South Carolina 2009.9. CSCE350 Algorithms and Data Structure.

Slides:



Advertisements
Similar presentations
Limitation of Computation Power – P, NP, and NP-complete
Advertisements

Reducibility Class of problems A can be reduced to the class of problems B Take any instance of problem A Show how you can construct an instance of problem.
CPE702 Complexity Classes Pruet Boonma Department of Computer Engineering Chiang Mai University Based on Material by Jenny Walter.
A. Levitin “Introduction to the Design & Analysis of Algorithms,” 3rd ed., Ch. 3 ©2012 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved.
S. J. Shyu Chap. 1 Introduction 1 The Design and Analysis of Algorithms Chapter 1 Introduction S. J. Shyu.
Advanced Topics in Algorithms and Data Structures Lecture 7.1, page 1 An overview of lecture 7 An optimal parallel algorithm for the 2D convex hull problem,
The Design and Analysis of Algorithms
Theory of Algorithms: Brute Force James Gain and Edwin Blake {jgain | Department of Computer Science University of Cape Town August.
COSC 3100 Brute Force and Exhaustive Search Instructor: Tanvir 1.
Lecture 8 Jianjun Hu Department of Computer Science and Engineering University of South Carolina CSCE350 Algorithms and Data Structure.
Design and Analysis of Algorithms - Chapter 31 Brute Force A straightforward approach usually based on problem statement and definitions Examples: 1. Computing.
Analysis & Design of Algorithms (CSCE 321)
Approximation Algorithms: Combinatorial Approaches Lecture 13: March 2.
1 -1 Chapter 1 Introduction Why Do We Need to Study Algorithms? To learn strategies to design efficient algorithms. To understand the difficulty.
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 21 Instructor: Paul Beame.
Chapter 3 Brute Force Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
Design and Analysis of Algorithms - Chapter 31 Brute Force A straightforward approach usually based on problem statement and definitions Examples: 1. Computing.
Homework page 102 questions 1, 4, and 10 page 106 questions 4 and 5 page 111 question 1 page 119 question 9.
Important Problem Types and Fundamental Data Structures
Lecture 6 Jianjun Hu Department of Computer Science and Engineering University of South Carolina CSCE350 Algorithms and Data Structure.
RAIK 283: Data Structures & Algorithms
CSCE350 Algorithms and Data Structure
IT 60101: Lecture #201 Foundation of Computing Systems Lecture 20 Classic Optimization Problems.
Complexity Classes (Ch. 34) The class P: class of problems that can be solved in time that is polynomial in the size of the input, n. if input size is.
Theory of Algorithms: Brute Force. Outline Examples Brute-Force String Matching Closest-Pair Convex-Hull Exhaustive Search brute-force strengths and weaknesses.
CS 200 Algorithms and Data Structures
DP TSP Have some numbering of the vertices We will think of all our tours as beginning and ending at 1 C(S, j) = length of shortest path visiting each.
1 Lower Bounds Lower bound: an estimate on a minimum amount of work needed to solve a given problem Examples: b number of comparisons needed to find the.
Brute Force A straightforward approach, usually based directly on the problem’s statement and definitions of the concepts involved Examples: Computing.
A. Levitin “Introduction to the Design & Analysis of Algorithms,” 3rd ed., Ch. 3 ©2012 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved.
5-1-1 CSC401 – Analysis of Algorithms Chapter 5--1 The Greedy Method Objectives Introduce the Brute Force method and the Greedy Method Compare the solutions.
Chapter 3 Brute Force. A straightforward approach, usually based directly on the problem’s statement and definitions of the concepts involved Examples:
Lecture 6 NP Class. P = ? NP = ? PSPACE They are central problems in computational complexity.
LIMITATIONS OF ALGORITHM POWER
COMP108 Algorithmic Foundations Polynomial & Exponential Algorithms
Lecture 25 NP Class. P = ? NP = ? PSPACE They are central problems in computational complexity.
© The McGraw-Hill Companies, Inc., Chapter 1 Introduction.
Onlinedeeneislam.blogspot.com1 Design and Analysis of Algorithms Slide # 1 Download From
Graphs Definition: a graph is an abstract representation of a set of objects where some pairs of the objects are connected by links. The interconnected.
Chapter 3 Brute Force Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
MA/CSSE 473 Day 12 Amortization (growable Array) Knuth interview Brute Force Examples.
Ch3 /Lecture #4 Brute Force and Exhaustive Search 1.
Exhaustive search Exhaustive search is simply a brute- force approach to combinatorial problems. It suggests generating each and every element of the problem.
Introduction to Algorithms: Brute-Force Algorithms.
Brute Force A straightforward approach, usually based directly on the problem’s statement and definitions of the concepts involved Examples: Computing.
Brute Force II.
Limitation of Computation Power – P, NP, and NP-complete
Brute Force A straightforward approach, usually based directly on the problem’s statement and definitions of the concepts involved Examples: Computing.
Brute Force A straightforward approach, usually based directly on the problem’s statement and definitions of the concepts involved Examples: Computing.
COMP108 Algorithmic Foundations Polynomial & Exponential Algorithms
Chapter 3 Brute Force Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
CSCE350 Algorithms and Data Structure
P and NP CISC4080, Computer Algorithms CIS, Fordham Univ.
Brute Force A straightforward approach, usually based directly on the problem’s statement and definitions of the concepts involved Examples – based directly.
Chapter 3 Brute Force Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
Chapter 3 String Matching.
Chapter 3 Brute Force Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
CSCE350 Algorithms and Data Structure
Richard Anderson Lecture 28 Coping with NP-Completeness
Chapter 3 Brute Force Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
Approximation Algorithms
Brute Force A straightforward approach, usually based directly on the problem’s statement and definitions of the concepts involved Examples: Computing.
Brute Force A straightforward approach, usually based directly on the problem’s statement and definitions of the concepts involved Examples: Computing.
Richard Anderson Lecture 30 NP-Completeness
3. Brute Force Selection sort Brute-Force string matching
3. Brute Force Selection sort Brute-Force string matching
CSC 380: Design and Analysis of Algorithms
3. Brute Force Selection sort Brute-Force string matching
Presentation transcript:

Lecture 7 Jianjun Hu Department of Computer Science and Engineering University of South Carolina CSCE350 Algorithms and Data Structure

Outline  Learning how to understand Pseudocodes of Mysterious programs  Brute Force Strategy for Algorithm Design  The art of lazy algorithm is to count/estimate its running time  Is it doable within given timeframe?

Sequential Search – Smallest Distance of Two numbers Find smallest distance between any 2 numbers What is time efficiency of this algorithm?

Sequential Search – Brute Force Find whether a search key is present in an array What is time efficiency of this algorithm?

Brute-Force String Matching Find a pattern in the text: Pattern – ‘NOT’, text – ‘NOBODY_NOTICED_HIM’ Typical Applications – ‘find’ function in the text editor, e.g., MS-Word, Google search What is the time efficiency of this algorithm?

Closest-Pair and Convex Hull Problems by Brute Force Closest-Pair problem Given n points in a plane, find the closest pair How to solve this problem and what is the time efficiency of this algorithm? Convex-Hull problem Convex hull is the tightest convex polygon that bounds a set of n points in a plane Convex polygon – any two points in this polygon results in the inclusion of the segment that links these two points also in this polygon

Closest-Pair problem Given n points in a plane, find the closest pair

Convex/NonConvex Polygons

Convex Hull Imagine a rubber band around a set of nails Nails touched by the band  extreme points

Solve Convex-Hull Problem  Connect any pair of points by a line segment.  Each line segment partitions the plane to the two half planes  If all the n points are on the same side of this line segment ax+by-c >0 or <0 Such a line segment is an edge of the convex-hull polygon  What is the time efficiency of this Brute-Force algorithm?  For each possible pair of points, we need to check whether all the remaining n-2 points are on the same side of the line segment that connects these pair of points.  For Sorting, String Matching, and Convex-Hull problems, we will revisit them by designing more efficient algorithms.

Exhaustive Search A brute-force approach to combinatorial problem Generate each and every element of the problem’s domain Then compare and select the desirable element that satisfies the set constraints Involve combinatorial objects such as permutations, combinations, and subsets of a given set The time efficiency is usually bad – usually the complexity grows exponentially with the input size Three examples Traveling salesman problem Knapsack problem Assignment problem

Traveling Salesman Problem Find the shortest tour through a given n cities that visits each city exactly once before returning to the starting city Using graph model: city  vertex, road  edge, length of the road  edge weight. TSP  shortest Hamiltonian Circuit – a cycle that passes through all the vertices of the graph exactly once Exhaustive search: List all the possible Hamiltonian circuits (starting from any vertex) Ignore the direction How many candidate circuits do we have?  (n-1)!/2 Very high complexity

TSP Example

Knapsack Problem Given n items of known weight w1, w2, …wn with values v1, v2,..vn, And a knapsack of capacity W How to select the items to fill the knapsack such that you get max value? Steal money from bank?