CSC 8301 Design and Analysis of Algorithms: Exhaustive Search

Similar documents
CSCE 350: Chin-Tser Huang. University of South Carolina

CSC Design and Analysis of Algorithms. Lecture 4 Brute Force, Exhaustive Search, Graph Traversal Algorithms. Brute-Force Approach

CSC 8301 Design and Analysis of Algorithms: Graph Traversal

Lecture 3. Brute Force

CS 440 Theory of Algorithms /

Computer Science 385 Design and Analysis of Algorithms Siena College Spring Topic Notes: Brute-Force Algorithms

CSC 8301 Design & Analysis of Algorithms: Linear Programming

Coping with the Limitations of Algorithm Power Exact Solution Strategies Backtracking Backtracking : A Scenario

Brute Force: Selection Sort

CSC 8301 Design & Analysis of Algorithms: Warshall s, Floyd s, and Prim s algorithms

More NP-complete Problems. CS255 Chris Pollett May 3, 2006.

CSE 417 Branch & Bound (pt 4) Branch & Bound

CSC 8301 Design and Analysis of Algorithms: Recursive Analysis

OPERATIONS RESEARCH. Transportation and Assignment Problems

Sankalchand Patel College of Engineering - Visnagar Department of Computer Engineering and Information Technology. Assignment

A 0 A 1... A i 1 A i,..., A min,..., A n 1 in their final positions the last n i elements After n 1 passes, the list is sorted.

CSC 1700 Analysis of Algorithms: Minimum Spanning Tree

Lecture 14: General Problem-Solving Methods

Backtracking and Branch-and-Bound

DESIGN AND ANALYSIS OF ALGORITHMS

CSC 8301 Design & Analysis of Algorithms: Kruskal s and Dijkstra s Algorithms

ECE6095: CAD Algorithms. Optimization Techniques

Introduction to Algorithms: Brute-Force Algorithms

CS6402-DESIGN AND ANALYSIS OF ALGORITHM. TWO MARK QUESTION WITH ANSWERS Unit-I. Introduction

Department of Computer Applications. MCA 312: Design and Analysis of Algorithms. [Part I : Medium Answer Type Questions] UNIT I

Introduction to Computer Science

Exercise 1. D-ary Tree

Anany Levitin 3RD EDITION. Arup Kumar Bhattacharjee. mmmmm Analysis of Algorithms. Soumen Mukherjee. Introduction to TllG DCSISFI &

L.J. Institute of Engineering & Technology Semester: VIII (2016)

Backtracking. Chapter 5

CSCE 321/3201 Analysis and Design of Algorithms. Prof. Amr Goneid. Fall 2016

DESIGN AND ANALYSIS OF ALGORITHMS

PSD1A. DESIGN AND ANALYSIS OF ALGORITHMS Unit : I-V

Recursion & Performance. Recursion. Recursion. Recursion. Where Recursion Shines. Breaking a Problem Down

Graphs and Algorithms

Topic Analysis PART-A

Final. Name: TA: Section Time: Course Login: Person on Left: Person on Right: U.C. Berkeley CS170 : Algorithms, Fall 2013

The Complexity of Algorithms (3A) Young Won Lim 4/3/18

INSTITUTE OF AERONAUTICAL ENGINEERING

Practice Problems for the Final

IV/IV B.Tech (Regular) DEGREE EXAMINATION. Design and Analysis of Algorithms (CS/IT 414) Scheme of Evaluation

2 Approximation Algorithms for Metric TSP

Practice Final Exam 1

Basic Search. Fall Xin Yao. Artificial Intelligence: Basic Search

CLASS: II YEAR / IV SEMESTER CSE CS 6402-DESIGN AND ANALYSIS OF ALGORITHM UNIT I INTRODUCTION

Theorem 2.9: nearest addition algorithm

UCSD CSE 21, Spring 2014 [Section B00] Mathematics for Algorithm and System Analysis

CSC 1700 Analysis of Algorithms: Heaps

Backtracking is a refinement of the brute force approach, which systematically searches for a

Computational problems. Lecture 2: Combinatorial search and optimisation problems. Computational problems. Examples. Example

Dr. Amotz Bar-Noy s Compendium of Algorithms Problems. Problems, Hints, and Solutions

P and NP CISC4080, Computer Algorithms CIS, Fordham Univ. Instructor: X. Zhang

Spanning Trees, greedy algorithms. Lecture 22 CS2110 Fall 2017

6. Algorithm Design Techniques

Lecture 1. Introduction

Computer Science and Software Engineering University of Wisconsin - Platteville. 3. Search (Part 1) CS 3030 Lecture Notes Yan Shi UW-Platteville

Notes for Lecture 24

Assignment 5: Solutions

P and NP CISC5835, Algorithms for Big Data CIS, Fordham Univ. Instructor: X. Zhang

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING QUESTION BANK UNIT-III. SUB NAME: DESIGN AND ANALYSIS OF ALGORITHMS SEM/YEAR: III/ II PART A (2 Marks)

5105 BHARATHIDASAN ENGINEERING COLLEGE

Traveling Salesman Problem Parallel Distributed Tree Search

CMSC 451: Lecture 22 Approximation Algorithms: Vertex Cover and TSP Tuesday, Dec 5, 2017

Massively Parallel Approximation Algorithms for the Traveling Salesman Problem

PATH FINDING AND GRAPH TRAVERSAL

1 5,9,2,7,6,10,4,3,8,1 The first number (5) is automatically the first number of the sorted list

Chapter 14. Graphs Pearson Addison-Wesley. All rights reserved 14 A-1

Search Algorithms. IE 496 Lecture 17

CMPSCI 250: Introduction to Computation. Lecture #24: General Search, DFS, and BFS David Mix Barrington 24 March 2014

10/31/18. About A6, Prelim 2. Spanning Trees, greedy algorithms. Facts about trees. Undirected trees

Review for Midterm Exam

Spanning Trees, greedy algorithms. Lecture 20 CS2110 Fall 2018

CSC 8301 Design and Analysis of Algorithms: Heaps

Graphs. Computer Science E-22 Harvard Extension School David G. Sullivan, Ph.D. What is a Graph? b d f h j

Discussion. What problems stretch the limits of computation? Compare 4 Algorithms. What is Brilliance? 11/11/11

Dynamic Programming Homework Problems

Computer Science 385 Design and Analysis of Algorithms Siena College Spring Topic Notes: Dynamic Programming

Seach algorithms The travelling salesman problem The Towers of Hanoi Playing games. Comp24412: Symbolic AI. Lecture 4: Search. Ian Pratt-Hartmann

Problem Solving, Search and Control Strategies

CS 170 DISCUSSION 8 DYNAMIC PROGRAMMING. Raymond Chan raychan3.github.io/cs170/fa17.html UC Berkeley Fall 17

Objectives and Homework List

Chapter-6 Backtracking

Math 3012 Combinatorial Optimization Worksheet

1. The Highway Inspector s Problem

Introduction to Algorithms

CPSC 320: Intermediate Algorithm Design and Analysis. Tutorial: Week 3

Module 11: Additional Topics Graph Theory and Applications

Dynamic programming. Trivial problems are solved first More complex solutions are composed from the simpler solutions already computed

(Refer Slide Time: 01:00)

Lecture 3: Graphs and flows

Assignment No 2 (Group B)

CS6402 DESIGN AND ANALYSIS OF ALGORITHMS QUESTION BANK UNIT I

15CS43: DESIGN AND ANALYSIS OF ALGORITHMS

Chapter 9 Graph Algorithms

Graphs. Computer Science E-119 Harvard Extension School Fall 2012 David G. Sullivan, Ph.D. What is a Graph? b d f h j

Traveling Salesman Problem: A Real World Scenario.

COMP 355 Advanced Algorithms Approximation Algorithms: VC and TSP Chapter 11 (KT) Section (CLRS)

Solving NP-hard Problems on Special Instances

Data Structures, Algorithms & Data Science Platforms

Using Templates to Introduce Time Efficiency Analysis in an Algorithms Course

Transcription:

CSC 8301 Design and Analysis of Algorithms: Exhaustive Search Professor Henry Carter Fall 2016

Recap Brute force is the use of iterative checking or solving a problem by its definition The straightforward approach Pros: Easy to understand Quick to build Cons: Usually inefficient Provides little insight into the problem 2

Combinatorics & Optimization Mathematical problems dealing with combinations, permutations, or optimizing parameters General problems seeking specific solutions The brute force solution: generate all solutions, select the best 3

Who s combining and optimizing? Many real-world problems reduce to combinatorial versions (e.g., routing, scheduling, logistical planning) Mathematically interesting! Combinatorics problems even show up on technical interviews (Two of) today s problems represent a special class of problems: NP-Hard NP-Hard problems have no known polynomial-time solution Arguably the greatest open question in computing 4

Common orders of growth 1 constant log n logarithmic n linear n logn n-log-n (linearithmic) n 2 quadratic n 3 cubic 2 n exponential n! factorial

Traveling Salesman Problem A salesman needs to visit n cities without repeating any. What is the cheapest route? In mathematical terms: given a weighted graph of n vertices, find a cycle that travels through every vertex exactly once 6

Example: TSP Tour Cost a b c d a 2+3+7+5 = 17 a b d c a 2+4+7+8 = 21 a c b d a 8+3+4+5 = 20 a c d b a 8+7+4+2 = 21 a d b c a 5+4+3+8 = 20 a d c b a 5+7+3+2 = 17 a 2 b 8 5 3 4 c 7 d 7

Knapsack Problem A thief is choosing from a set of n objects, where each object has a value v i and a weight w i. With a knapsack of capacity c, find the most valuable subset of objects In mathematical terms: Given a set of n objects with value v i and weight w i and a maximum capacity c, find the subset of objects with the highest total value v and a total weight w < c 8

Example: Knapsack Example: Knapsack capacity W=16 item weight value 1. 2 $20 2. 5 $30 3. 10 $50 4. 5 $10 9

Example: Knapsack Subset Total weight Total value {1} 2 $20 {2} 5 $30 {3} 10 $50 {4} 5 $10 {1,2} 7 $50 {1,3} 12 $70 {1,4} 7 $30 {2,3} 15 $80 {2,4} 10 $40 {3,4} 15 $60 {1,2,3} 17 not feasible {1,2,4} 12 $60 {1,3,4} 17 not feasible {2,3,4} 20 not feasible {1,2,3,4} 22 not feasible 10

Example: Knapsack 11

Assignment Problem There are n people who need to be assigned to n jobs. The ith person has a cost C i,j for working the jth job. Find a job assignment that minimizes the total cost. In mathematical terms: Given a matrix of costs C, select one entry in each row such that there is only one selection in each column and the sum of the costs is minimized 12

Example: Assignment 9 2 7 8 C = 6 4 3 7 5 8 1 8 7 6 9 4 Assignment (col.#s) Total Cost 1, 2, 3, 4 9+4+1+4=18 1, 2, 4, 3 9+4+8+9=30 1, 3, 2, 4 9+3+8+4=24 1, 3, 4, 2 9+3+8+6=26 1, 4, 2, 3 9+7+8+9=33 1, 4, 3, 2 9+7+1+6=23 etc. 13

Example: Assignment 14

Good news, everyone! Unlike the first two problems, the assignment problem is in P (a polynomial time algorithm is known) Hungarian mathematicians developed a O(n 4 ) algorithm Further optimizations have been developed since 15

8 Queens Problem How many different ways can you arrange 8 queens without endangering any of them? 16

8 Queens Problem 92 unique solutions How many different positions are there so that: No two queens are on the same square? No two queens are on the same row? No two queens are on the same row OR in the same column? 17

Exhaustive (Graph) Search Graphs are a very common construction in computer science Specially structured graphs called trees are a common way to store data How do we search graph vertices in an ordered fashion? 18

Mathematical Graphs A set of vertices and edges that connect them Trees are graphs with no cycles (loops) Common representation: Adjacency matrix Adjacency list 19

Depth-First Search Searches vertices by moving as far as possible from the starting node Produces a set of trees containing the searched vertices called a Depth-First Search Forest Implemented with a stack (last in first out) data structure (or a recursive call stack) 20

DFS Algorithm 21

DFS: Example Graph 22

DFS: Analysis List: Matrix: 23

Practice f c b e d a g 24

Who cares? Mathematical: graph connectivity, acyclicity, etc. Foundation for iterative deepening tree search Often applied to AI search spaces (e.g., determining which move to make in chess, solving a maze) File Systems arranged as trees can be traversed using DFS 25

Next Time... Levitin Chapter 3.5, 4.1-4.2 Remember, you need to read it BEFORE you come to class! Homework 3.4: 1, 4 3.5: 1, 2, 3 26