WEEK 1 CLASS NOTES AARON G. CASS
|
|
- Phebe Bond
- 6 years ago
- Views:
Transcription
1 WEEK 1 LSS NOTES RON G. SS Sc 250, Spring 2009 aron G. ass epartment of omputer Science Union ollege ELERITY PROLEM celebrity is a person known by all, but who knows nobody. In the celebrity problem, we are given a set of people and asked to find a celebrity within that group. We are allowed to ask questions of the form oes know?. Theorem 1 (Uniqueness of elebrity). In a set S of n people, there can be only one celebrity. Proof. ssume for contradiction that there are two celebrities 1 and 2. y definition of celebrity, everyone knows a celebrity. Therefore α S { 1 }, α knows 1. ecause 2 S { 1 }, 2 knows 1. ut celebrities don t know anyone. Therefore, 2 is not a celebrity. This contradicts our assumption that 2 was a celebrity. Therefore the assumption is false. Therefore, we cannot have two celebrities. POSSILE LGORITHMS FOR THE ELERITY PROLEM The first algorithm is based on a brute-force approach. We essentially look at each pair of people to see if they know each other. If we find a person that knows nobody but is known by all the others, that person is a celebrity: ELERITY(S) Input: set S of n people Output: a celebrity, or no celebrity if there is no celebrity 1: for each S do 2: for each S {} do 3: if knows then 4: break out of inner loop 5: else 6: 7: for each α in S do 8: if α does not know then 9: return no celebrity 10: return This algorithm runs in O(n 2 ) time. an we do better? Yes, we can. The following algorithm is based on the observation that by asking a single question, we can eliminate a person as a possible celebrity. So, if I ask oes know? and the answer is no, then cannot be a celebrity, because a celebrity must be known by everybody else. On the other hand, if the answer is yes, then cannot be a celebrity because a celebrity knows nobody. Therefore, with a single question oes know?, we learn something no matter what the answer to the question is. This leads to this algorithm: ELERITY(S) Input: set S of n people Output: a celebrity, or no celebrity if there is no celebrity 1: andidates = S 2: while andidates > 0 do 3: choose and, such that andidates and andidates 4: if knows then 7 pril 2009 aron G. ass 1
2 5: andidates = andidates {} 6: else 7: andidates = andidates {} 8: Let be the only remaining element of andidates 9: for each α in S {} do 10: if α does not know or knows α then 11: return no celebrity 12: return The first loop here runs n 1 times because every time around the loop we eliminate a possibility (and we stop when there is one possibility left). The second loop runs for n 1 times also because we let α take on S 1 different values. Therefore the overall running time is in O(n). WHT IS N LGORITHM? Problem lgorithm Input "omputer" Output n algorithm is a description of an unambiguous sequence of operations that take any valid input and produce correct output: unambiguous The description must be clear to the reader. sequence of operations The description must make clear what order the operations should be carried out in. This could be a step-by-step description, but can also include things like loops, procedure calls, etc... any valid input If the algorithm does not produce correct output for all inputs, it is not a correct algorithm. correct output Of course, the algorithm should describe how to produce correct output. EULIEN TRVELLING SLESPERSON (ETSP) Problem: Find a minimal-length tour (cycle) of a set of points in the plane. Input: Set S of n points in the plane ((x, y) pairs) Output: Permutation P of points from S such that tour P 1, P 2, P 3,..., P n, P 1 has total cost no more than any other tour of the points in S. NEREST NEIGHOR ETSP The first algorithmic idea that comes to mind for solving ETSP is one where we 1) pick a starting point and then 2) keep finding the next closest point to continue our path: NERESTNEIGHORETSP(S) Input: set S of n (x, y) points Output: permutation of S representing the best tour of S 1: pick and visit a point p o S 2: i 0 7 pril 2009 aron G. ass 2
3 3: while there are unvisited points do 4: i i + 1 5: select p i closest unvisited point to p i 1 6: visit p i 7: return p o, p 1, p 2,..., p n 1 This algorithm is easy to understand, efficient (O(n 2 )), and easy to implement. Unfortunately, it does not work. To show this, we only need to look at one counter-example: Note that the algorithm does not say where to start, so as the adversary we can choose where to start such that we get an incorrect answer. In this example, if we start at the point in the upper-left corner, the algorithm produces the tour shown on the left. However, the tour shown on the right is clearly better. Here s another case where the algorithm fails. gain, we choose to start in the middle because that makes things worse Note that, again, the algorithm does not specify what to do when two points are equidistant from our current point. In this example, we choose to break the tie in the way that causes the most back-tracking. learly, the optimal solution to this instance of the problem should be to start at one end (say, the left) and visit each point from one end to the other (say, from left to right). The solution our algorithm gives is much worse than this. STRTING T THE LEFT, MOIFIE NEREST NEIGHOR ETSP ased on the previous example, we had the idea that maybe we should start at the left-most point so that we avoid the trouble. However, that also doesn t work, as shown in this example, which is the same as the previous example, except 1) it s turned on it s side and 2) an extra point is added to force the algorithm to start near the middle: 7 pril 2009 aron G. ass 3
4 LOSEST PIR ETSP In the Nearest Neighbor algorithm, we always have a single partial path. We start with a single node and then add to the path at one end. Here s an algorithm that instead tries to choose short edges for the tour, but it does not keep a single partial path at all times: LOSESTPIRETSP(S) Input: set S of n (x, y) points Output: best tour of S 1: n S 2: for i 1 to n 1 do 3: d infty 4: for each pair (x, y), where x and y are endpoints from different partial paths do 5: if dist(x, y) d then 6: x m x 7: y m y 8: d dist(x, y) 7 pril 2009 aron G. ass 4
5 9: connect x m and y m by an edge 10: connect endpoints by an edge to complete tour 11: return the tour The inner for loop finds the pair of points that s closest to each other, as long as the two points are endpoints of partial paths. If we didn t restrict ourselves to endpoints, we could create a branching tour (which isn t really a tour). Unfortunately, this algorithm doesn t work either. Here are some counterexamples: In this example, we consider four points, three in a line and one above that line, as shown in the top of the figure. The optimal solution is shown at the bottom of the figure, with length: Our algorithm produces the tour in the middle, with length In this example, we have eight points close to each other on an arc, with another point far away from those points. ecause the points on the far left are further apart than the ones a little bit to their right, the ones to the right are connected first. y the time we have connected the eight points on the left, the furthest left points are the end-points of their partial path. Therefore, the far away point must be connected to those points, even though a shorter tour can be had by connecting it to the closer points. 7 pril 2009 aron G. ass 5
6 In this example, the six points are in a simple grid, with the rows closer together than the columns. ecause the rows are closer, the three vertical edges are created first. Then, we have a choice for the fourth edge. However, once the fourth edge is added, the fifth one must be the one diagonally opposite it (the other possible edges do not connect points that are end-points of different partial paths). learly, the solution our algorithm arrives at (the top figure) is worse than the optional solution (on the bottom). NP-OMPLETE PROLEMS The NP-omplete problems are a set of problems for which there is no known polynomial time algorithm. version of ETSP is one such problem, so no known polytime algorithm is known for ETSP. It s possible there is a polynomial time algorithm, but most people think that it doesn t work. So, right now, the best known algorithm for ETSP is one where each permutation is computed to choose the best one. While this algorithm runs in O(n!) time, this is the best known algorithm at this time. GRPH PROLEMS ETSP is a special version of the general travelling salesperson problem defined for weighted, undirected graphs: Given a weighted undirected graph, find the tour of the nodes in the graph with minimal total edge weight. In order to understand this, we must understand what a graph is. Here we will introduce the basic terminology of graphs please see ppendix of your text [1] for more. graph G = (V, E) is a set of vertices V and a set of edges E that connect them. Each edge e in E is a pair of vertices (x, y), where x V and y V we say that the vertices x and y are connected by the edge (x, y). We usually draw graphs by creating a labelled circle for each vertex and drawing a line connecting two circles if the two corresponding vertices are connected in the graph. For example, G = (V, E), where V = {,,, } and E = {(, ), (, ), (, ), (, )} is drawn like so: 7 pril 2009 aron G. ass 6
7 In this graph, we say that is connected to. We also say that is connected to because this is an undirected graph the edges do not have a defined direction. On the other hand, a directed graph has edges that are not symmetric, and are usually drawn with arrow-heads at the ends of the line segments that connect circles. For example, G = (V, E), where V = {,,, } and E = {(, ), (, ), (, ), (, ), (, )}, is shown below: Note that an edge connects to, but no edge connects to. lso note that both (, ) and (, ) exist in the edge set and are drawn as one edge with two arrowheads in the diagram. weighted graph is a set of vertices, a set of edges connecting vertices, and a weight function that maps pairs of vertices to real numbers. onsider the following weighted undirected graph: Formally, this graph is G = (V, E, ω), where V = {,,, }, E = {(, ), (, ), (, ), (, )}, and ω is defined as: 4 if x = and y = 8 if x = and y = ω(x, y) = 3.2 if x = and y = 5 if x = and y = otherwise Note that any of these graphs can have self-loops edges from a node to itself. REPRESENTTION OF GRPHS There are two common ways of representing graphs. In an adjacency matrix representation, an n-node graph is represented by an n n oolean matrix, where a cell (x, y) in the matrix has a value true if and only if there is an edge between the vertices x an y in the graph. For example, for the graph shown here: The adjacency matrix is: 7 pril 2009 aron G. ass 7
8 F T F F T F T T F T F T F T T F Note that for a weighted graph, you also need a matrix that gives the edge weights for each pair of vertices. The other common representation is to use adjacency lists, where for each vertex, we keep a linked-list of its adjacent vertices. So, the same graph shown above has the following adjacency list: Note that in both of these representations, edges in undirected graphs are represented by two directed edges in the representation. So, there is an entry in the adjacency list for vertex and also an entry in the adjacency list for vertex. lso note that adjacency lists use space efficiently for sparse graphs, little space is used because the representation does not represent non-edges. On the other hand, determining whether two vertices are connected can be done in constant time using an adjacency matrix, but requires a linear search if we use adjacency lists. RUNNING TIME NLYSIS In running time analysis, we count basic operations and then use big-o notation to classify the function that describes that count. For example, for problems with input size n, we might say that one algorithm solves it in O(n) time while another one solves it in O(n log n) time. From previous courses, we have an informal notion of big-o, but let s give a formal definition: EFINITION OF IG-O f(n) O(g(n)) n 0 0, c > 0 : n n 0 : f(n) c g(n) This defines a set of functions that are all related to g(n) in this way (though they may have different constants n 0 and c). Note that n 0 and c are constants in this definition. You can only say that f(n) O(g(n)) if you can find constants that make this true, no matter what values of n someone tries. asically, this says that, above some threshold, f(n) is bounded by a constant factor of g(n), no matter how big n gets. The definition does not say anything about how the functions compare below the threshold. Note also that the definition does not say specifically what constants n 0 and c make this true it only says that such constants exist. Here s a graphical representation of this definition. Note that in this diagram I m showing f(n) above c g(n) for n less than n 0. Remember, though, the definition does not say anything about f(n) below n 0. 7 pril 2009 aron G. ass 8
9 c g(n) f(n) n 0 When f(n) O(g(n)), you will hear people say: f is bounded above by g. f is bounded above by a constant factor of g. f grows no faster than g. EFINTION OF IG-Θ Here s the analogous definition of big-θ, which is used to talk about tight asymptotic bounds, where we know not just an upper bound, but also a lower bound: EFINITION OF IG-Ω f(n) Θ(g(n)) n 0 0, c 1 > 0, c 2 > 0 : n n 0 : c 1 g(n) f(n) c 2 g(n) Here s the analogous definition for big-ω, which we use for lower-bounds. f(n) Ω(g(n)) n 0 0, c > 0 : n n 0 : f(n) c g(n) REFERENES [1] Thomas H. ormen, harles E. Leiserson, Ronald L. Rivest, and lifford Stein. Introduction to lgorithms. The MIT Press, second edition, pril 2009 aron G. ass 9
PROGRAM EFFICIENCY & COMPLEXITY ANALYSIS
Lecture 03-04 PROGRAM EFFICIENCY & COMPLEXITY ANALYSIS By: Dr. Zahoor Jan 1 ALGORITHM DEFINITION A finite set of statements that guarantees an optimal solution in finite interval of time 2 GOOD ALGORITHMS?
More informationAsymptotic Analysis Spring 2018 Discussion 7: February 27, 2018
CS 61B Asymptotic Analysis Spring 2018 Discussion 7: February 27, 2018 1 Asymptotic Notation 1.1 Order the following big-o runtimes from smallest to largest. O(log n), O(1), O(n n ), O(n 3 ), O(n log n),
More informationUCSD CSE 101 MIDTERM 1, Winter 2008
UCSD CSE 101 MIDTERM 1, Winter 2008 Andrew B. Kahng / Evan Ettinger Feb 1, 2008 Name: }{{} Student ID: }{{} Read all of the following information before starting the exam. This test has 3 problems totaling
More informationChapter 2: Complexity Analysis
Chapter 2: Complexity Analysis Objectives Looking ahead in this chapter, we ll consider: Computational and Asymptotic Complexity Big-O Notation Properties of the Big-O Notation Ω and Θ Notations Possible
More informationAlgorithms and Data Structures
Algorithms and Data Structures Spring 2019 Alexis Maciel Department of Computer Science Clarkson University Copyright c 2019 Alexis Maciel ii Contents 1 Analysis of Algorithms 1 1.1 Introduction.................................
More information(Refer Slide Time: 02.06)
Data Structures and Algorithms Dr. Naveen Garg Department of Computer Science and Engineering Indian Institute of Technology, Delhi Lecture 27 Depth First Search (DFS) Today we are going to be talking
More informationCS 4349 Lecture October 18th, 2017
CS 4349 Lecture October 18th, 2017 Main topics for #lecture include #minimum_spanning_trees. Prelude Homework 6 due today. Homework 7 due Wednesday, October 25th. Homework 7 has one normal homework problem.
More informationDefinition f(n) = O(g(n)) if there exists n 0, c such that for all n n 0, f(n) cg(n). g is an asymptotic upper bound on f.
Announcements CMPSC 311: ntroduction to Algorithms Akshay Krishnamurthy University of Massachusetts Homework 1 released (Due 2/7 11:59pm) Quiz 1 out (Due 1/30 11:59pm) Discussion section Friday Last Compiled:
More informationNotebook Assignments
Notebook Assignments These six assignments are a notebook using techniques from class in the single concrete context of graph theory. This is supplemental to your usual assignments, and is designed for
More informationCSE 101, Winter Discussion Section Week 1. January 8 - January 15
CSE 101, Winter 2018 Discussion Section Week 1 January 8 - January 15 Important Annotations were added (post-lecture) to the tablet slides, to fill in a few gaps (Lecture 1) Look through Additional Resources
More informationComputational Geometry
Lecture 12: Lecture 12: Motivation: Terrains by interpolation To build a model of the terrain surface, we can start with a number of sample points where we know the height. Lecture 12: Motivation: Terrains
More informationSeparators in High-Genus Near-Planar Graphs
Rochester Institute of Technology RIT Scholar Works Theses Thesis/Dissertation Collections 12-2016 Separators in High-Genus Near-Planar Graphs Juraj Culak jc1789@rit.edu Follow this and additional works
More informationPROBLEM 4
PROBLEM 2 PROBLEM 4 PROBLEM 5 PROBLEM 6 PROBLEM 7 PROBLEM 8 PROBLEM 9 PROBLEM 10 PROBLEM 11 PROBLEM 12 PROBLEM 13 PROBLEM 14 PROBLEM 16 PROBLEM 17 PROBLEM 22 PROBLEM 23 PROBLEM 24 PROBLEM 25
More informationCSE 146. Asymptotic Analysis Interview Question of the Day Homework 1 & Project 1 Work Session
CSE 146 Asymptotic Analysis Interview Question of the Day Homework 1 & Project 1 Work Session Comparing Algorithms Rough Estimate Ignores Details Or really: independent of details What are some details
More informationCSE 332: Data Structures & Parallelism Lecture 19: Introduction to Graphs. Ruth Anderson Autumn 2018
SE 332: ata Structures & Parallelism Lecture 19: Introduction to Graphs Ruth nderson utumn 2018 Today Graphs Intro & efinitions 11/19/2018 2 Graphs graph is a formalism for representing relationships among
More informationasymptotic growth rate or order compare two functions, but ignore constant factors, small inputs
Big-Oh 1 asymptotic growth rate or order 2 compare two functions, but ignore constant factors, small inputs asymptotic growth rate or order 2 compare two functions, but ignore constant factors, small inputs
More informationThe angle measure at for example the vertex A is denoted by m A, or m BAC.
MT 200 ourse notes on Geometry 5 2. Triangles and congruence of triangles 2.1. asic measurements. Three distinct lines, a, b and c, no two of which are parallel, form a triangle. That is, they divide the
More informationDistributed minimum spanning tree problem
Distributed minimum spanning tree problem Juho-Kustaa Kangas 24th November 2012 Abstract Given a connected weighted undirected graph, the minimum spanning tree problem asks for a spanning subtree with
More informationIntroduction to Algorithms
Introduction to Algorithms 6.046J/18.401 Lecture 21 Prof. Piotr Indyk P vs NP (interconnectedness of all things) A whole course by itself We ll do just two lectures More in 6.045, 6.840J, etc. Introduction
More informationBasic Combinatorics. Math 40210, Section 01 Fall Homework 4 Solutions
Basic Combinatorics Math 40210, Section 01 Fall 2012 Homework 4 Solutions 1.4.2 2: One possible implementation: Start with abcgfjiea From edge cd build, using previously unmarked edges: cdhlponminjkghc
More informationCS 61B Asymptotic Analysis Fall 2018
CS 6B Asymptotic Analysis Fall 08 Disclaimer: This discussion worksheet is fairly long and is not designed to be finished in a single section Some of these questions of the level that you might see on
More informationTreewidth and graph minors
Treewidth and graph minors Lectures 9 and 10, December 29, 2011, January 5, 2012 We shall touch upon the theory of Graph Minors by Robertson and Seymour. This theory gives a very general condition under
More informationPractice Problems for the Final
ECE-250 Algorithms and Data Structures (Winter 2012) Practice Problems for the Final Disclaimer: Please do keep in mind that this problem set does not reflect the exact topics or the fractions of each
More informationLecture 22 Tuesday, April 10
CIS 160 - Spring 2018 (instructor Val Tannen) Lecture 22 Tuesday, April 10 GRAPH THEORY Directed Graphs Directed graphs (a.k.a. digraphs) are an important mathematical modeling tool in Computer Science,
More informationCPSC 320 Sample Solution, Playing with Graphs!
CPSC 320 Sample Solution, Playing with Graphs! September 23, 2017 Today we practice reasoning about graphs by playing with two new terms. These terms/concepts are useful in themselves but not tremendously
More informationCS240 Fall Mike Lam, Professor. Algorithm Analysis
CS240 Fall 2014 Mike Lam, Professor Algorithm Analysis Algorithm Analysis Motivation: what and why Mathematical functions Comparative & asymptotic analysis Big-O notation ("Big-Oh" in textbook) Analyzing
More information[ 11.2, 11.3, 11.4] Analysis of Algorithms. Complexity of Algorithms. 400 lecture note # Overview
400 lecture note #0 [.2,.3,.4] Analysis of Algorithms Complexity of Algorithms 0. Overview The complexity of an algorithm refers to the amount of time and/or space it requires to execute. The analysis
More informationU.C. Berkeley CS170 : Algorithms, Fall 2013 Midterm 1 Professor: Satish Rao October 10, Midterm 1 Solutions
U.C. Berkeley CS170 : Algorithms, Fall 2013 Midterm 1 Professor: Satish Rao October 10, 2013 Midterm 1 Solutions 1 True/False 1. The Mayan base 20 system produces representations of size that is asymptotically
More informationSEARCHING, SORTING, AND ASYMPTOTIC COMPLEXITY
1 A3 and Prelim 2 SEARCHING, SORTING, AND ASYMPTOTIC COMPLEXITY Lecture 11 CS2110 Fall 2016 Deadline for A3: tonight. Only two late days allowed (Wed-Thur) Prelim: Thursday evening. 74 conflicts! If you
More informationPractice Final Exam 1
Algorithm esign Techniques Practice Final xam Instructions. The exam is hours long and contains 6 questions. Write your answers clearly. You may quote any result/theorem seen in the lectures or in the
More informationNP-Complete Problems
1 / 34 NP-Complete Problems CS 584: Algorithm Design and Analysis Daniel Leblanc 1 1 Senior Adjunct Instructor Portland State University Maseeh College of Engineering and Computer Science Winter 2018 2
More informationCS/ENGRD 2110 Object-Oriented Programming and Data Structures Spring 2012 Thorsten Joachims. Lecture 10: Asymptotic Complexity and
CS/ENGRD 2110 Object-Oriented Programming and Data Structures Spring 2012 Thorsten Joachims Lecture 10: Asymptotic Complexity and What Makes a Good Algorithm? Suppose you have two possible algorithms or
More informationDr. Amotz Bar-Noy s Compendium of Algorithms Problems. Problems, Hints, and Solutions
Dr. Amotz Bar-Noy s Compendium of Algorithms Problems Problems, Hints, and Solutions Chapter 1 Searching and Sorting Problems 1 1.1 Array with One Missing 1.1.1 Problem Let A = A[1],..., A[n] be an array
More informationData Structures and Algorithms Chapter 2
1 Data Structures and Algorithms Chapter 2 Werner Nutt 2 Acknowledgments The course follows the book Introduction to Algorithms, by Cormen, Leiserson, Rivest and Stein, MIT Press [CLRST]. Many examples
More informationIntroduction to Graph Theory
Introduction to Graph Theory Tandy Warnow January 20, 2017 Graphs Tandy Warnow Graphs A graph G = (V, E) is an object that contains a vertex set V and an edge set E. We also write V (G) to denote the vertex
More informationExercise 1. D-ary Tree
CSE 101: Design and Analysis of Algorithms Winter 2018 Homework 1 Solutions Due: 01/19/2018, 11.59 PM Exercise 1. D-ary Tree A d-ary tree is a rooted tree in which each node has at most d children. Show
More informationSolving Linear Recurrence Relations (8.2)
EECS 203 Spring 2016 Lecture 18 Page 1 of 10 Review: Recurrence relations (Chapter 8) Last time we started in on recurrence relations. In computer science, one of the primary reasons we look at solving
More informationCSE 373 APRIL 3 RD ALGORITHM ANALYSIS
CSE 373 APRIL 3 RD ALGORITHM ANALYSIS ASSORTED MINUTIAE HW1P1 due tonight at midnight HW1P2 due Friday at midnight HW2 out tonight Second Java review session: Friday 10:30 ARC 147 TODAY S SCHEDULE Algorithm
More informationCS302 Topic: Algorithm Analysis. Thursday, Sept. 22, 2005
CS302 Topic: Algorithm Analysis Thursday, Sept. 22, 2005 Announcements Lab 3 (Stock Charts with graphical objects) is due this Friday, Sept. 23!! Lab 4 now available (Stock Reports); due Friday, Oct. 7
More informationCPSC 320: Intermediate Algorithm Design and Analysis. Tutorial: Week 3
CPSC 320: Intermediate Algorithm Design and Analysis Author: Susanne Bradley Tutorial: Week 3 At the time of this week s tutorial, we were approaching the end of our stable matching unit and about to start
More informationCS1800 Discrete Structures Spring 2017 Profs. Gold & Schnyder April 28, CS1800 Discrete Structures Final
S1800 Discrete Structures Spring 2017 Profs. Gold & Schnyder pril 28, 2017 S1800 Discrete Structures Final Instructions: 1. The exam is closed book and closed notes. You may not use a calculator or any
More informationCS 4349 Lecture August 21st, 2017
CS 4349 Lecture August 21st, 2017 Main topics for #lecture include #administrivia, #algorithms, #asymptotic_notation. Welcome and Administrivia Hi, I m Kyle! Welcome to CS 4349. This a class about algorithms.
More informationCOT 5407: Introduction to Algorithms. Giri Narasimhan. ECS 254A; Phone: x3748
COT 5407: Introduction to Algorithms Giri Narasimhan ECS 254A; Phone: x3748 giri@cis.fiu.edu http://www.cis.fiu.edu/~giri/teach/5407s17.html https://moodle.cis.fiu.edu/v3.1/course/view.php?id=1494 8/28/07
More informationData Structures and Algorithms. Part 2
1 Data Structures and Algorithms Part 2 Werner Nutt 2 Acknowledgments The course follows the book Introduction to Algorithms, by Cormen, Leiserson, Rivest and Stein, MIT Press [CLRST]. Many examples displayed
More informationCSE373: Data Structures and Algorithms Lecture 4: Asymptotic Analysis. Aaron Bauer Winter 2014
CSE373: Data Structures and Algorithms Lecture 4: Asymptotic Analysis Aaron Bauer Winter 2014 Previously, on CSE 373 We want to analyze algorithms for efficiency (in time and space) And do so generally
More informationPlanar Graphs and Surfaces. Graphs 2 1/58
Planar Graphs and Surfaces Graphs 2 1/58 Last time we discussed the Four Color Theorem, which says that any map can be colored with at most 4 colors and not have two regions that share a border having
More informationELEC-270 Solutions to Assignment 5
ELEC-270 Solutions to Assignment 5 1. How many positive integers less than 1000 (a) are divisible by 7? (b) are divisible by 7 but not by 11? (c) are divisible by both 7 and 11? (d) are divisible by 7
More information/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Approximation algorithms Date: 11/27/18
601.433/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Approximation algorithms Date: 11/27/18 22.1 Introduction We spent the last two lectures proving that for certain problems, we can
More informationLecture 6: Graph Properties
Lecture 6: Graph Properties Rajat Mittal IIT Kanpur In this section, we will look at some of the combinatorial properties of graphs. Initially we will discuss independent sets. The bulk of the content
More informationGraphs: Definitions and Representations (Chapter 9)
oday s Outline Graphs: efinitions and Representations (hapter 9) dmin: HW #4 due hursday, Nov 10 at 11pm Memory hierarchy Graphs Representations SE 373 ata Structures and lgorithms 11/04/2011 1 11/04/2011
More informationDynamic Programming II
Lecture 11 Dynamic Programming II 11.1 Overview In this lecture we continue our discussion of dynamic programming, focusing on using it for a variety of path-finding problems in graphs. Topics in this
More informationSoftware Analysis. Asymptotic Performance Analysis
Software Analysis Performance Analysis Presenter: Jonathan Aldrich Performance Analysis Software Analysis 1 Asymptotic Performance Analysis How do we compare algorithm performance? Abstract away low-level
More informationSteven Skiena. skiena
Lecture 22: Introduction to NP-completeness (1997) Steven Skiena Department of Computer Science State University of New York Stony Brook, NY 11794 4400 http://www.cs.sunysb.edu/ skiena Among n people,
More informationMidterm 1 Solutions. (i) False. One possible counterexample is the following: n n 3
CS 170 Efficient Algorithms & Intractable Problems, Spring 2006 Midterm 1 Solutions Note: These solutions are not necessarily model answers. Rather, they are designed to be tutorial in nature, and sometimes
More informationMergeSort, Recurrences, Asymptotic Analysis Scribe: Michael P. Kim Date: April 1, 2015
CS161, Lecture 2 MergeSort, Recurrences, Asymptotic Analysis Scribe: Michael P. Kim Date: April 1, 2015 1 Introduction Today, we will introduce a fundamental algorithm design paradigm, Divide-And-Conquer,
More informationGraphs: Definitions and Representations (Chapter 9)
oday s Outline Graphs: efinitions and Representations (hapter 9) SE 373 ata Structures and lgorithms dmin: Homework #4 - due hurs, Nov 8 th at 11pm Midterm 2, ri Nov 16 Memory hierarchy Graphs Representations
More informationAlgorithm Analysis. (Algorithm Analysis ) Data Structures and Programming Spring / 48
Algorithm Analysis (Algorithm Analysis ) Data Structures and Programming Spring 2018 1 / 48 What is an Algorithm? An algorithm is a clearly specified set of instructions to be followed to solve a problem
More informationWhy study algorithms? CS 561, Lecture 1. Today s Outline. Why study algorithms? (II)
Why study algorithms? CS 561, Lecture 1 Jared Saia University of New Mexico Seven years of College down the toilet - John Belushi in Animal House Q: Can I get a programming job without knowing something
More informationSimple Graph. General Graph
Graph Theory A graph is a collection of points (also called vertices) and lines (also called edges), with each edge ending at a vertex In general, it is allowed for more than one edge to have the same
More information(Refer Slide Time: 1:27)
Data Structures and Algorithms Dr. Naveen Garg Department of Computer Science and Engineering Indian Institute of Technology, Delhi Lecture 1 Introduction to Data Structures and Algorithms Welcome to data
More informationIntroduction to Data Structure
Introduction to Data Structure CONTENTS 1.1 Basic Terminology 1. Elementary data structure organization 2. Classification of data structure 1.2 Operations on data structures 1.3 Different Approaches to
More informationPSD1A. DESIGN AND ANALYSIS OF ALGORITHMS Unit : I-V
PSD1A DESIGN AND ANALYSIS OF ALGORITHMS Unit : I-V UNIT I -- Introduction -- Definition of Algorithm -- Pseudocode conventions -- Recursive algorithms -- Time and space complexity -- Big- o notation --
More informationRUNNING TIME ANALYSIS. Problem Solving with Computers-II
RUNNING TIME ANALYSIS Problem Solving with Computers-II Performance questions 4 How efficient is a particular algorithm? CPU time usage (Running time complexity) Memory usage Disk usage Network usage Why
More information1 Counting triangles and cliques
ITCSC-INC Winter School 2015 26 January 2014 notes by Andrej Bogdanov Today we will talk about randomness and some of the surprising roles it plays in the theory of computing and in coding theory. Let
More informationBasic Euclidean Geometry
hapter 1 asic Euclidean Geometry This chapter is not intended to be a complete survey of basic Euclidean Geometry, but rather a review for those who have previously taken a geometry course For a definitive
More information1 Definition of Reduction
1 Definition of Reduction Problem A is reducible, or more technically Turing reducible, to problem B, denoted A B if there a main program M to solve problem A that lacks only a procedure to solve problem
More informationCS240 Fall Mike Lam, Professor. Algorithm Analysis
CS240 Fall 2014 Mike Lam, Professor Algorithm Analysis HW1 Grades are Posted Grades were generally good Check my comments! Come talk to me if you have any questions PA1 is Due 9/17 @ noon Web-CAT submission
More informationTHE DNA INEQUALITY POWER ROUND
THE DNA INEQUALITY POWER ROUND Instructions Write/draw all solutions neatly, with at most one question per page, clearly numbered. Turn in the solutions in numerical order, with your team name at the upper
More informationSearch in discrete and continuous spaces
UNSW COMP3431: Robot Architectures S2 2006 1 Overview Assignment #1 Answer Sheet Search in discrete and continuous spaces Due: Start of Lab, Week 6 (1pm, 30 August 2006) The goal of this assignment is
More informationElementary maths for GMT. Algorithm analysis Part II
Elementary maths for GMT Algorithm analysis Part II Algorithms, Big-Oh and Big-Omega An algorithm has a O( ) and Ω( ) running time By default, we mean the worst case running time A worst case O running
More informationCS:3330 (22c:31) Algorithms
What s an Algorithm? CS:3330 (22c:31) Algorithms Introduction Computer Science is about problem solving using computers. Software is a solution to some problems. Algorithm is a design inside a software.
More informationCOMP3121/3821/9101/ s1 Assignment 1
Sample solutions to assignment 1 1. (a) Describe an O(n log n) algorithm (in the sense of the worst case performance) that, given an array S of n integers and another integer x, determines whether or not
More information4.4 Algorithm Design Technique: Randomization
TIE-20106 76 4.4 Algorithm Design Technique: Randomization Randomization is one of the design techniques of algorithms. A pathological occurence of the worst-case inputs can be avoided with it. The best-case
More informationSection 05: Solutions
Section 05: Solutions 1. Asymptotic Analysis (a) Applying definitions For each of the following, choose a c and n 0 which show f(n) O(g(n)). Explain why your values of c and n 0 work. (i) f(n) = 5000n
More informationIntroduction to Algorithms / Algorithms I Lecturer: Michael Dinitz Topic: Approximation algorithms Date: 11/18/14
600.363 Introduction to Algorithms / 600.463 Algorithms I Lecturer: Michael Dinitz Topic: Approximation algorithms Date: 11/18/14 23.1 Introduction We spent last week proving that for certain problems,
More informationAlgorithms for Euclidean TSP
This week, paper [2] by Arora. See the slides for figures. See also http://www.cs.princeton.edu/~arora/pubs/arorageo.ps Algorithms for Introduction This lecture is about the polynomial time approximation
More informationPolynomial-Time Approximation Algorithms
6.854 Advanced Algorithms Lecture 20: 10/27/2006 Lecturer: David Karger Scribes: Matt Doherty, John Nham, Sergiy Sidenko, David Schultz Polynomial-Time Approximation Algorithms NP-hard problems are a vast
More informationAlgorithm. Algorithm Analysis. Algorithm. Algorithm. Analyzing Sorting Algorithms (Insertion Sort) Analyzing Algorithms 8/31/2017
8/3/07 Analysis Introduction to Analysis Model of Analysis Mathematical Preliminaries for Analysis Set Notation Asymptotic Analysis What is an algorithm? An algorithm is any well-defined computational
More informationCS261: A Second Course in Algorithms Lecture #16: The Traveling Salesman Problem
CS61: A Second Course in Algorithms Lecture #16: The Traveling Salesman Problem Tim Roughgarden February 5, 016 1 The Traveling Salesman Problem (TSP) In this lecture we study a famous computational problem,
More informationsuch a manner that we are able to understand, grasp and grapple with the problem at hand in a more organized fashion.
Programming and Data Structure Dr.P.P.Chakraborty Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Lecture 32 Conclusions Hello everybody. Today, we come to the
More informationThe Cut Locus and the Jordan Curve Theorem
The Cut Locus and the Jordan Curve Theorem Rich Schwartz November 19, 2015 1 Introduction A Jordan curve is a subset of R 2 which is homeomorphic to the circle, S 1. The famous Jordan Curve Theorem says
More informationLet s use a more formal definition. An angle is the union of two rays with a common end point.
hapter 2 ngles What s the secret for doing well in geometry? Knowing all the angles. s we did in the last chapter, we will introduce new terms and new notations, the building blocks for our success. gain,
More informationDiscrete mathematics , Fall Instructor: prof. János Pach
Discrete mathematics 2016-2017, Fall Instructor: prof. János Pach - covered material - Lecture 1. Counting problems To read: [Lov]: 1.2. Sets, 1.3. Number of subsets, 1.5. Sequences, 1.6. Permutations,
More informationGrade 7/8 Math Circles Fall Nov.4/5 The Pythagorean Theorem
1 Faculty of Mathematics Waterloo, Ontario Centre for Education in Mathematics and Computing Grade 7/8 Math Circles Fall 2014 - Nov.4/5 The Pythagorean Theorem Introduction A right triangle is any triangle
More informationInstant Insanity Instructor s Guide Make-it and Take-it Kit for AMTNYS 2006
Instant Insanity Instructor s Guide Make-it and Take-it Kit for AMTNYS 2006 THE KIT: This kit contains materials for two Instant Insanity games, a student activity sheet with answer key and this instructor
More informationCOMP260 Spring 2014 Notes: February 4th
COMP260 Spring 2014 Notes: February 4th Andrew Winslow In these notes, all graphs are undirected. We consider matching, covering, and packing in bipartite graphs, general graphs, and hypergraphs. We also
More informationval(y, I) α (9.0.2) α (9.0.3)
CS787: Advanced Algorithms Lecture 9: Approximation Algorithms In this lecture we will discuss some NP-complete optimization problems and give algorithms for solving them that produce a nearly optimal,
More informationTopic C. Communicating the Precision of Measured Numbers
Topic C. Communicating the Precision of Measured Numbers C. page 1 of 14 Topic C. Communicating the Precision of Measured Numbers This topic includes Section 1. Reporting measurements Section 2. Rounding
More informationIntroduction to Algorithms 6.046J/18.401J/SMA5503
Introduction to Algorithms 6.046J/18.401J/SMA5503 Lecture 1 Prof. Charles E. Leiserson Welcome to Introduction to Algorithms, Fall 01 Handouts 1. Course Information. Calendar 3. Registration (MIT students
More informationIntroduction III. Graphs. Motivations I. Introduction IV
Introduction I Graphs Computer Science & Engineering 235: Discrete Mathematics Christopher M. Bourke cbourke@cse.unl.edu Graph theory was introduced in the 18th century by Leonhard Euler via the Königsberg
More informationLast week: Breadth-First Search
1 Last week: Breadth-First Search Set L i = [] for i=1,,n L 0 = {w}, where w is the start node For i = 0,, n-1: For u in L i : For each v which is a neighbor of u: If v isn t yet visited: - mark v as visited,
More informationA simple problem that has a solution that is far deeper than expected!
The Water, Gas, Electricity Problem A simple problem that has a solution that is far deeper than expected! Consider the diagram below of three houses and three utilities: water, gas, and electricity. Each
More information10/5/2016. Comparing Algorithms. Analyzing Code ( worst case ) Example. Analyzing Code. Binary Search. Linear Search
10/5/2016 CSE373: Data Structures and Algorithms Asymptotic Analysis (Big O,, and ) Steve Tanimoto Autumn 2016 This lecture material represents the work of multiple instructors at the University of Washington.
More informationQuiz 1 Solutions. (a) f(n) = n g(n) = log n Circle all that apply: f = O(g) f = Θ(g) f = Ω(g)
Introduction to Algorithms March 11, 2009 Massachusetts Institute of Technology 6.006 Spring 2009 Professors Sivan Toledo and Alan Edelman Quiz 1 Solutions Problem 1. Quiz 1 Solutions Asymptotic orders
More informationLecture 7: Asymmetric K-Center
Advanced Approximation Algorithms (CMU 18-854B, Spring 008) Lecture 7: Asymmetric K-Center February 5, 007 Lecturer: Anupam Gupta Scribe: Jeremiah Blocki In this lecture, we will consider the K-center
More informationWhat Is An Algorithm? Algorithms are the ideas behind computer programs. An algorithm is the thing which stays the same whether
What Is An Algorithm? Algorithms are the ideas behind computer programs An algorithm is the thing which stays the same whether the program is in Pascal running on a Cray innew York or is in BASIC running
More informationGrades 7 & 8, Math Circles 31 October/1/2 November, Graph Theory
Faculty of Mathematics Waterloo, Ontario N2L 3G1 Centre for Education in Mathematics and Computing Grades 7 & 8, Math Circles 31 October/1/2 November, 2017 Graph Theory Introduction Graph Theory is the
More informationAnother Sorting Algorithm
1 Another Sorting Algorithm What was the running time of insertion sort? Can we do better? 2 Designing Algorithms Many ways to design an algorithm: o Incremental: o Divide and Conquer: 3 Divide and Conquer
More informationCMPSCI611: The SUBSET-SUM Problem Lecture 18
CMPSCI611: The SUBSET-SUM Problem Lecture 18 We begin today with the problem we didn t get to at the end of last lecture the SUBSET-SUM problem, which we also saw back in Lecture 8. The input to SUBSET-
More information0.1 Welcome. 0.2 Insertion sort. Jessica Su (some portions copied from CLRS)
0.1 Welcome http://cs161.stanford.edu My contact info: Jessica Su, jtysu at stanford dot edu, office hours Monday 3-5 pm in Huang basement TA office hours: Monday, Tuesday, Wednesday 7-9 pm in Huang basement
More information