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.

Slides:



Advertisements
Similar presentations
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.
Advertisements

§3 Shortest Path Algorithms Given a digraph G = ( V, E ), and a cost function c( e ) for e  E( G ). The length of a path P from source to destination.
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.
Counting the bits Analysis of Algorithms Will it run on a larger problem? When will it fail?
Greed is good. (Some of the time)
Lecture 24 Coping with NPC and Unsolvable problems. When a problem is unsolvable, that's generally very bad news: it means there is no general algorithm.
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.
Least squares CS1114
Zhang Hongyi CSCI2100B Data Structures Tutorial 2
Chapter 3 The Greedy Method 3.
1 Chapter 11 l Basics of Recursion l Programming with Recursion Recursion.
Clustering and greedy algorithms — Part 2 Prof. Noah Snavely CS1114
3 -1 Chapter 3 The Greedy Method 3 -2 The greedy method Suppose that a problem can be solved by a sequence of decisions. The greedy method has that each.
CPSC 411, Fall 2008: Set 4 1 CPSC 411 Design and Analysis of Algorithms Set 4: Greedy Algorithms Prof. Jennifer Welch Fall 2008.
Discrete Structures & Algorithms EECE 320 : UBC : Spring 2009 Matei Ripeanu 1.
Algorithm Efficiency and Sorting
1 Algorithms and Analysis CS 2308 Foundations of CS II.
CPSC 411, Fall 2008: Set 4 1 CPSC 411 Design and Analysis of Algorithms Set 4: Greedy Algorithms Prof. Jennifer Welch Fall 2008.
1 Minimum Spanning Trees Longin Jan Latecki Temple University based on slides by David Matuszek, UPenn, Rose Hoberman, CMU, Bing Liu, U. of Illinois, Boting.
Minimum Spanning Trees. Subgraph A graph G is a subgraph of graph H if –The vertices of G are a subset of the vertices of H, and –The edges of G are a.
1 Minimum Spanning Trees Longin Jan Latecki Temple University based on slides by David Matuszek, UPenn, Rose Hoberman, CMU, Bing Liu, U. of Illinois, Boting.
Minimum Spanning Trees What is a MST (Minimum Spanning Tree) and how to find it with Prim’s algorithm and Kruskal’s algorithm.
Minimum Spanning Tree in Graph - Week Problem: Laying Telephone Wire Central office.
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.
CMSC 150 INTRODUCTION TO COMPUTING CS 150: Mon 9 Jan 2012.
Data Structures and Algorithms Graphs Minimum Spanning Tree PLSD210.
CS223 Algorithms D-Term 2013 Instructor: Mohamed Eltabakh WPI, CS Introduction Slide 1.
Minimal Spanning Trees What is a minimal spanning tree (MST) and how to find one.
Analysis of Algorithms
Algorithmic Foundations COMP108 COMP108 Algorithmic Foundations Greedy methods Prudence Wong
© The McGraw-Hill Companies, Inc., Chapter 3 The Greedy Method.
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.
1 Ethics of Computing MONT 113G, Spring 2012 Session 13 Limits of Computer Science.
Week 5 - Monday.  What did we talk about last time?  Linked list implementations  Stacks  Queues.
Types of IP Models All-integer linear programs Mixed integer linear programs (MILP) Binary integer linear programs, mixed or all integer: some or all of.
Minimum Spanning Trees CSE 2320 – Algorithms and Data Structures Vassilis Athitsos University of Texas at Arlington 1.
Module 5 – Networks and Decision Mathematics Chapter 23 – Undirected Graphs.
Binary Search From solving a problem to verifying an answer.
TECH Computer Science NP-Complete Problems Problems  Abstract Problems  Decision Problem, Optimal value, Optimal solution  Encodings  //Data Structure.
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.
알고리즘 설계 및 분석 Foundations of Algorithm 유관우. Digital Media Lab. 2 Chap4. Greedy Approach Grabs data items in sequence, each time with “best” choice, without.
CSC 211 Data Structures Lecture 13
CSE 589 Part VI. Reading Skiena, Sections 5.5 and 6.8 CLR, chapter 37.
Review 1 Arrays & Strings Array Array Elements Accessing array elements Declaring an array Initializing an array Two-dimensional Array Array of Structure.
Graphs A ‘Graph’ is a diagram that shows how things are connected together. It makes no attempt to draw actual paths or routes and scale is generally inconsequential.
Computability NP complete problems. Space complexity. Homework: [Post proposal]. Find PSPACE- Complete problems. Work on presentations.
CS216: Program and Data Representation University of Virginia Computer Science Spring 2006 David Evans Lecture 8: Crash Course in Computational Complexity.
Harbin, China 2010 finals ACM today… ! (2009) Knapsack DP for NP! Floyd-Warshall DP for APSP! Max Flow.
ACM today The Fall competition is getting organized… it's going to be lonely…
Applied Discrete Mathematics Week 2: Functions and Sequences
Randomized Min-Cut Algorithm
Week 13: Searching and Sorting
COMP108 Algorithmic Foundations Greedy methods
ACM so far… Sep 6 Welcome! and DP problems ~ 5 problems
IGCSE 6 Cambridge Effectiveness of algorithms Computer Science
Lesson Objectives Aims Understand the following “standard algorithms”:
Jotto! Frosh Sophs Jrs Srs audio 2 audio 1 audio 2 audio 1 graze 2
Minimum Spanning Tree.
Minimum Spanning Tree.
CSE 373 Data Structures and Algorithms
Searching CLRS, Sections 9.1 – 9.3.
Minimum Spanning Tree.
CSE 373: Data Structures and Algorithms
Compact routing schemes with improved stretch
Minimum spanning trees
CSE 373: Data Structures and Algorithms
Lecture 14 Minimum Spanning Tree (cont’d)
Algorithms Tutorial 27th Sept, 2019.
Presentation transcript:

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...

ACM today Some nice unix commands… This week: binary search problems... Paul Dorsey will talk next week at this time... “Nice” enforcement One of our Nice enforcers!

ACM today Some nice unix commands… This week: binary search problems... “Nice” enforcement Paul Dorsey will talk next week at this time... be sure to be NICE ! Remote broadcast message (Tue Feb 1 21:59: ): Attention Knuth users: if you are currently experiencing excruciating slowness, that is because several people have been running Practicum problems without nicing them. THIS IS BAD. If you think that a program you are running might be using a lot of CPU and/or RAM for longer than a few seconds, please nice it like so: nice -n 19 [your process] If you've already started running a process that you think might need to be niced, there are plenty of ways to do so: 1. Invoke "renice" from the command line: renice -n 19 [process id] 2. Open "top", hit 'r', and type in the PID of the process you want to renice, and then give it the priority (19 unless you have good reason to do otherwise). 3. Open "htop", find your process, and repeatedly hit F8 to increase its niceness.

top screen nice Make sure long-running programs are nice ! top watches the progress of all of knuth's processes. What are are all of these columns saying? Creates a terminal session independent of a particular connection screen particularly this one… nice! screen screen -r to start to resume nice java args +19

Next week This talk is optional It is 1.5 problems... It might count as a colloquium, too... last term's talks were good!

Course Schedule Jan 25 Welcome! DP + other problems ~ 4 problems Feb 1 Lab session ~ 4 problems Feb 8 Discussion session on graph problems ~ 4 problems Feb 15 Paul Dorsey ~ 4 problems Feb 22 Lab session on bin search problems and others... ~ 4 problems Mar 1 Discussion session on geometry problems ~ 4 problems Mar 1 Traveling – no CS 189 class Mar 8 Lab session on geometry problems ~ 4 problems Mar 15 Spring break... – no CS 189 class Mar 22 Discussion session on something new... ~ 4 problems Mar 29 Lab session ~ 4 problems... we don't meet through April... You may submit problems until the end of exams… ≥ 32 problems total

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

Binary search in a sorted list... LOW Is an item "present" – or is a problem solvable? MIDHIGH 1 1,

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 cables 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: (Prim’s algorithm) Start anywhere and repeatedly choose the next- smallest edge out from your current tree.

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

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

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

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

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

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

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

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

MST Minimum spanning tree: (Prim’s 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...

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!?