Jotto! JRsSRsElderly slate 3 This term's first class to guess another's word earns 1 problem... slate 2slate 1 This term's last class to have its word.

Slides:



Advertisements
Similar presentations
Algorithm Design Techniques
Advertisements

and 6.855J Cycle Canceling Algorithm. 2 A minimum cost flow problem , $4 20, $1 20, $2 25, $2 25, $5 20, $6 30, $
Introduction to Algorithms
Polygon Scan Conversion – 11b
9.1 Si23_03 SI23 Introduction to Computer Graphics Lecture 9 – Clipping.
Graph Algorithms - 3 Algorithm Design and Analysis Victor AdamchikCS Spring 2014 Lecture 13Feb 12, 2014Carnegie Mellon University.
Improved Shortest Path Algorithms for Nearly Acyclic Directed Graphs L. Tian and T. Takaoka University of Canterbury New Zealand 2007.
Algorithms Algorithm: what is it ?. Algorithms Algorithm: what is it ? Some representative problems : - Interval Scheduling.
Chapter 4: Informed Heuristic Search
Greedy Technique Constructs a solution to an optimization problem piece by piece through a sequence of choices that are: feasible, i.e. satisfying the.
ALG0183 Algorithms & Data Structures Lecture 23 a acyclic with neg. weights (topological sort algorithm) 8/25/20091 ALG0183 Algorithms & Data Structures.
Chapter 10: Applications of Arrays and the class vector
1 ACM Programming Contest Nov 3, Introduction ACM organized such contests from1977 Contest Regional Qualifying Final Purpose provides college.
Chapter 9 -- Simplification of Sequential Circuits.
Make sure you know the day and time of the final exam for this section of Math 110: Day: ______ Date:______ Time: ______ to _______ All Math 110.
1 Breadth First Search s s Undiscovered Discovered Finished Queue: s Top of queue 2 1 Shortest path from s.
CS1022 Computer Programming & Principles
1 Motion and Manipulation Configuration Space. Outline Motion Planning Configuration Space and Free Space Free Space Structure and Complexity.
25 seconds left…...
Week 1.
Lilian Blot CORE ELEMENTS SELECTION & FUNCTIONS Lecture 3 Autumn 2014 TPOP 1.
CS203 Lecture 15.
Bottoms Up Factoring. Start with the X-box 3-9 Product Sum
Instructor: Shengyu Zhang 1. Content Two problems  Minimum Spanning Tree  Huffman encoding One approach: greedy algorithms 2.
Epp, section 10.? CS 202 Aaron Bloomfield
all-pairs shortest paths in undirected graphs
Chapter 9: Graphs Shortest Paths
Social network partition Presenter: Xiaofei Cao Partick Berg.
Jotto! JRsSRs other diner 1 This term's first class to guess another's word earns 1 problem... diner 1diner 2 This term's last class to have its word guessed.
2/9/06CS 3343 Analysis of Algorithms1 Convex Hull  Given a set of pins on a pinboard  And a rubber band around them  How does the rubber band look when.
Lecture 3: Parallel Algorithm Design
Jotto! JRsSRsElderly A word-guessing game similar to mastermind… slate 3 This term's first class to guess another's word earns 1 problem... slate 2slate.
ACM so far… Sep 11 Welcome! and DP problems ~ 6 problems Sep 18 Lab session ~ 6 problems Sep 25 Discussion session on graph problems ~ 6 problems Oct 2.
Brute-Force Triangulation
Convex Hull obstacle start end Convex Hull Convex Hull
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,
8/29/06CS 6463: AT Computational Geometry1 CS 6463: AT Computational Geometry Spring 2006 Convex Hulls Carola Wenk.
1 Today’s Material Computational Geometry Problems –Closest Pair Problem –Convex Hull Jarvis’s March, Graham’s scan –Farthest Point Problem.
Jotto! SophsJrsSrs audio 1audio 2audio 1 Frosh audio 2 graze 3graze 1 graze 2 alloy 1 alloy 2 fresh 2fresh 1fresh 2fresh 1 This term's first class to guess.
6/2/ :35 AMIncremental Convex Hull1 q w u e zt.
Spring 2010CS 2251 Graphs Chapter 10. Spring 2010CS 2252 Chapter Objectives To become familiar with graph terminology and the different types of graphs.
Shortest Path Problems Directed weighted graph. Path length is sum of weights of edges on path. The vertex at which the path begins is the source vertex.
Lection 1: Introduction Computational Geometry Prof.Dr.Th.Ottmann 1 History: Proof-based, algorithmic, axiomatic geometry, computational geometry today.
ACM Schedule… 2/23 Geometry problems 3/2 Lab problems (geometry!) 3/30 "Mock" competition and lab session (4:15) 3/9 Final algorithm discussion… 3/16 [Spring.
CSE53111 Computational Geometry TOPICS q Preliminaries q Point in a Polygon q Polygon Construction q Convex Hulls Further Reading.
ACM Welcome! Sep 11 Welcome! and DP problems ~ 6 problems Sep 18 Lab session ~ 6 problems Sep 25 Discussion session on graph problems ~ 6 problems Oct.
Convex Hull. What is the Convex Hull? Imagine a set of points on a board with a nail hammered into each point. Now stretch a rubber band over all the.
CompSci 6 Introduction to Computer Science October 20, 2011 Prof. Rodger.
ACM today! Nice work to everyone in the qualifiers and evening lab... Today: BS! Next 11/2: guest speaker... On 11/9: final lab session 11/13: regionals.
Curricularizing the ACM... ? Zach Dodds ~ November 13, 2010.
ACM programming contest Introduction + Recursion.
ACM reminders October HMC Mock contest 9: :30 November regional contest This is the next ACM meeting !! Contest-like problems dynamic.
Robert Pless, CS 546: Computational Geometry Lecture #3 Last time Several convex hull algorithms. Lower bound of O(n log n) –O(n log h) for output sensitive.
Lecture 12 CSE 331 Sep 28, Upcoming Important Dates Tuesday Oct 8 (~1.5 weeks) Mini Project group compositions Monday Oct 12 (2 weeks) Quiz 1 Monday.
Harbin, China 2010 finals ACM today… ! (2009) Knapsack DP for NP! Floyd-Warshall DP for APSP! Max Flow.
Sorting With Priority Queue In-place Extra O(N) space
ACM so far… Sep 6 Welcome! and DP problems ~ 5 problems
Lesson Objectives Aims Understand the following “standard algorithms”:
Convex Hull.
Algorithm design techniques Dr. M. Gavrilova
Jotto! Frosh Sophs Jrs Srs audio 2 audio 1 audio 2 audio 1 graze 2
Algorithmics and Programming II: Introduction
Convex Hull obstacle start end 11/21/2018 4:05 AM Convex Hull
Computational Geometry Capter:1-2.1
Convex Sets & Concave Sets
Jotto! Sophs Jrs Srs Profs pluot 1 pluot 2 pluot 1 pluot 2 squid 2
Convex Hull 1/1/ :28 AM Convex Hull obstacle start end.
ACM today… ! DP for NP! DP for APSP! Knapsack Floyd-Warshall
Convex Hull obstacle start end 4/30/2019 5:21 PM Convex Hull
CSE 417: Algorithms and Computational Complexity
Presentation transcript:

Jotto! JRsSRsElderly slate 3 This term's first class to guess another's word earns 1 problem... slate 2slate 1 This term's last class to have its word guessed earns 1 problem... Sophs slate 1 flair 0flair 1flair 2flair 0 Pomona slate 3 flair 2 stems 3stems 1stems 2stems 1stems 2 loser 2loser 3loser 2loser 1loser 3 stone 3stone 1 stone 2 guppy 1guppy 0guppy 1guppy 2guppy 0

Upcoming schedule... Sep 6 Welcome! and DP problems ~ 5 problems Sep 13 Lab session ~ 4 problems Sep 20 Discussion session on graph problems ~ 4 problems Sep 27 Lab session on graph problems ~ 4 problems Oct 4 Discussion session on geometry problems ~ 4 problems Oct 11 Lab session on geometry problems ~ 4 problems Oct 18 Lab & local ACM qualifying contest ~ 6 problems Oct 25 Discussion session on something new!! ~ 4 problems Nov 1 Lab session ~ 4 problems Nov 8 No meeting (organizing teams to Riverside...) Nov 12 (Sat.) ACM Regional contest (in Riverside...) Nov 15 Final meeting (may be a make-up lab if we miss one) You may submit problems until the end of exams… 38 problems total

HMC-local contest... Tuesday, October 18 9pm-1am Top four (Java/C/C++)teams have the chance to go to the regionals at Riverside Lab - and lab scoring - for everyone… (you need not stay all four hours!)

Regional contest...

Application-themed contest?!

Today's algorithms… SSSP single-source shortest paths Binary Search Dijkstra's algorithm Convex Hull Last Time... This time!

Dijkstra's shortest-paths algorithm Single-source shortest paths to all vertices… S B E C D Maintain a list of Accessible [dist, node] pairs Expand the closest node and Retire it… src Accessible Retired A = [ [ 0,S] ] R = [ ] Step 0Setup 60 Step 1Step 2Step 3Step 4

Dijkstra? APL is a mistake, carried through to perfection. It is the language of the future for the programming techniques of the past: it creates a new generation of coding bums. Edsger Dijkstra Computer science is no more about computers than astronomy is about telescopes. Edsger Dijkstra You probably know that arrogance, in computer science, is measured in nanodijkstras. Alan Kay, keynote speech at OOPSLA 1997 [2] during the "structured programming" wars

goto in Python…

Also this week: binary search If a desired value is difficult to compute but easy to check 1d (or broken into 1d subproblems) then we can binary search across all the possible values for it, checking as we go... ! and monotonic (true for all n T)

Also this week: binary search Python example

Last week: phoneline Input Output # of telephone poles, N 4 The smallest largest cable needed to connect #1 and #N # of edges available # of cables you get for free need to connect #1 and #N

"Monotone-chain" Convex Hull Note that, looking, all turns are left turns! vertices of the smallest polygon containing all points

Monotone-chain Convex Hull Let's find the BOTTOM chain for this set of points…

Monotone-chain Convex Hull Idea: find the upper hull and lower hull... (Start-up) sort the point-list P by x-coordinate (then y) Let P be all the points (sorted) Convex_Hull (Lower hull) for each point P[0]..P[i]..P[N]: P while L[-2], L[-1], P[i] are not CCW: remove L[-1] append P[i] to L (Upper hull) same – but in reverse direction! Let L=[] start the list of lower hull points…

Code... def convex_hull(points): """ Input: an iterable sequence of (x, y) pairs representing the points. Output: a list of vertices of the convex hull in counter-clockwise order, starting from the vertex with the lexicographically smallest coordinates. Implements Andrew's monotone chain algorithm. O(n log n) complexity. """ points = sorted(set(points)) if len(points) <= 1: return points def cross(o, a, b): return (a[0] - o[0]) * (b[1] - o[1]) - (a[1] - o[1]) * (b[0] - o[0]) # Build lower hull lower = [] for p in points: while len(lower) >= 2 and cross(lower[-2], lower[-1], p) <= 0: lower.pop() lower.append(p) # Build upper hull upper = [] for p in reversed(points): while len(upper) >= 2 and cross(upper[-2], upper[-1], p) <= 0: upper.pop() upper.append(p) return lower[:-1] + upper[:-1] # Example: convex hull of a 10-by-10 grid. assert convex_hull([(i/10, i%10) for i in range(100)]) == [(0, 0), (9, 0), (9, 9), (0, 9)]

This week… convex hull binary search Dijkstra!

Jotto! JRsSRsElderly slate 3 This term's first class to guess another's word earns 1 problem... slate 2slate 1 This term's last class to have its word guessed earns 1 problem... Sophs slate 1 flair 0flair 1flair 2flair 0 Pomona slate 3 flair 2 stems 3stems 1stems 2stems 1stems 2 loser 2loser 3loser 2loser 1loser 3 stone 3stone 1 stone 2 guppy 1guppy 0guppy 1guppy 2guppy 0

Binary search in a sorted list... available on the ACM website in Python

This week: aggr Input Output Number of stalls in which cows can be placed The locations of stalls Number of cows to house in the new barn… 3 The largest minimum spacing possible after placing the cows

aggr in Python (in part) # get the # of stalls (N) and cows (C) S = [] for i in range(N): S += [input()] # get the stalls' locations S.sort() # sort them lo = 0 hi = max(S)-min(S)+1 input

aggr in Python (in part) # get the # of stalls (N) and cows (C) S = [] for i in range(N): S += [input()] # get the stalls' locations S.sort() # sort them lo = 0 hi = max(S)-min(S)+1 while True: mid = (lo + hi)/2 # no overflow in Python, right? if mid == hi or mid == lo: break # does mid work? if CHECKS_OUT( mid, C, S ): lo = mid # worked! look higher (set lo to mid) else: hi = mid # did not work... look lower (set hi to mid) print mid binary search input still left to do?

This bug went undetected in Java's libraries for years...

This week's problems… phoneline hunger aggr cowblank btwr this problem is only for those new to ACM... but if you're returning, you can solve it in web-form for credit: you should use HTML 5's canvas object directly (or libraries that use it) to draw the scenario and results...

Web versions! Web frameworks are welcome... As are libraries, e.g., JQuery and its variants The locations of stalls This week: HMTL 5 canvas objects cows!

This week's problems… phoneline hunger aggr cowblank btwr this problem is only for those new to ACM... but if you're returning, you can solve it in web-form for credit: you should use HTML 5's canvas object directly (or libraries that use it) to draw the scenario and results...

This week: phoneline Input Output # of telephone poles, N 4 The minimium possible length of remaining largest cable needed to connect #1 and #N # of edges available # of cables you get for free #1 is connected to the phone network

MST Minimum spanning tree: (Prims algorithm) Start anywhere and repeatedly choose the next- smallest edge out from your current tree.

MST Minimum spanning tree: (Prims algorithm) Start anywhere and repeatedly choose the next- smallest edge out from your current tree.

MST Minimum spanning tree: (Prims algorithm) Start anywhere and repeatedly choose the next- smallest edge out from your current tree.

MST Minimum spanning tree: (Prims algorithm) Start anywhere and repeatedly choose the next- smallest edge out from your current tree.

MST Minimum spanning tree: (Prims algorithm) Start anywhere and repeatedly choose the next- smallest edge out from your current tree.

MST Minimum spanning tree: (Prims algorithm) Start anywhere and repeatedly choose the next- smallest edge out from your current tree.

MST Minimum spanning tree: (Prims algorithm) Start anywhere and repeatedly choose the next- smallest edge out from your current tree.

MST Minimum spanning tree: (Prims algorithm) Start anywhere and repeatedly choose the next- smallest edge out from your current tree.

MST Minimum spanning tree: (Prims algorithm) Start anywhere and repeatedly choose the next- smallest edge out from your current tree.

MST Minimum spanning tree: (Prims algorithm) Start anywhere and repeatedly choose the next- smallest edge out from your current tree. Done!

Try this week's problems! phoneline hunger aggr cowblank btwr this problem is only for those new to ACM... but if you're returning, you can solve it in web-form for credit: you should use HTML 5's canvas object directly (or libraries that use it) to draw the scenario and results...

Jotto! SophsJrsSrs audio 1audio 2audio 1 Frosh audio 2 graze 3graze 1 graze 2 alloy 1 alloy 2 fresh 2fresh 1fresh 2fresh 1 This term's first class to guess another's word earns 1 problem... This term's last class to have its word guessed earns 1 problem... armor 2 armor 1armor 2 brave 3brave 1 brave 2

Last week: wifi InputOutput The # of access points and the # of houses The # of test cases... Locations of the houses The smallest max distance achievable

This week: city Input Output dist cost of 1 st story # of people to house 194 The minimium cost to house the specified # of people cost per unit distance from (0,0) maximum # of stories per building the central station where everyone works is at (0,0) distances to it are considered to be |x|+|y|-1 0 dist 1 dist 2 dist 1 dist 3 dist

This week: cowset Input Output ID # for 1 st cow # of cows available, up to 34 5 The number of subsets whose IDs sum between min and max minimum ID sum maximum ID sum Farmer Ran is willing to play frisbee with any subset of cows whose IDs sum to any value between the min and max... ID # for 2 nd cow ID # for 3 rd cow Try all subsets...?

This week: cowset Input Output ID # for 1 st cow # of cows available, up to 34 5 The number of subsets whose IDs sum between min and max minimum ID sum maximum ID sum Farmer Ran is willing to play frisbee with any subset of cows whose IDs sum to any value between the min and max... ID # for 2 nd cow ID # for 3 rd cow Takes too long to try all subsets...! How could Bin Search speed it up?

Problem D from the 2009 World Finals in Stockholm: Pipe Packing Given a set of four wire diameters: What is the minimum diameter of pipe that can contain all four wires? (Constraint: pipes only come in millimeter sizes)

A lower bound: sum of largest two wire-diameters An upper bound: sum of all four wire-diameters l Binary search between lower bound and upper bound l Given a pipe diameter and four wire diameters, can you pack the wires inside the pipe? l Choose the smallest integer pipe diameter that fits Intuition: Solve this problem by binary search

Problem D from the 2009 World Finals in Stockholm: Pipe Packing Given a set of four wire diameters: What is the minimum diameter of pipe that can contain all four wires? (Constraint: pipes only come in millimeter sizes)

A lower bound: sum of largest two wire-diameters An upper bound: sum of all four wire-diameters l Binary search between lower bound and upper bound l Given a pipe diameter and four wire diameters, can you pack the wires inside the pipe? l Choose the smallest integer pipe diameter that fits Intuition: Solve this problem by binary search

ACM this week!?