Department of Mathematics and Computer Science University of Southern Denmark, Odense. Exercises for Week 47 on. Online Algorithms

Similar documents
Online Algorithms. - Lecture 4 -

Primality Testing. Public-Key Cryptography needs large prime numbers How can you tell if p is prime? Try dividing p by all smaller integers

Lecture 1: An Introduction to Online Algorithms

CMPSCI611: Approximating SET-COVER Lecture 21

princeton univ. F 17 cos 521: Advanced Algorithm Design Lecture 24: Online Algorithms

Online Algorithms. Lecture Notes for CSCI 570 by David Kempe December 1, 2006

Approximation Algorithms

Advanced Algorithms. On-line Algorithms

COMP Online Algorithms. Online Bin Packing. Shahin Kamali. Lecture 20 - Nov. 16th, 2017 University of Manitoba

Comp Online Algorithms

Lecture 8 Sept 25, 2014

Comp Online Algorithms

Lecture Overview. 2 Online Algorithms. 2.1 Ski rental problem (rent-or-buy) COMPSCI 532: Design and Analysis of Algorithms November 4, 2015

Algorithmen II. Peter Sanders, Christian Schulz, Simon Gog. Übungen: Michael Axtmann. Institut für Theoretische Informatik, Algorithmik II.

Welcome to the course Algorithm Design

Approximation Algorithms

Efficient Online Strategies for Renting Servers in the Cloud. Shahin Kamali, Alejandro López-Ortiz. University of Waterloo, Canada.

Online Algorithms. Lecture 11

Parallel and Sequential Data Structures and Algorithms Lecture (Spring 2012) Lecture 16 Treaps; Augmented BSTs

15-451/651: Design & Analysis of Algorithms November 4, 2015 Lecture #18 last changed: November 22, 2015

SFU CMPT Lecture: Week 8

Batch Coloring of Graphs

Introduction to Algorithms / Algorithms I Lecturer: Michael Dinitz Topic: Algorithms and Game Theory Date: 12/3/15

CS261: A Second Course in Algorithms Lecture #14: Online Bipartite Matching

/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Approximation algorithms Date: 11/27/18

COS 423 Lecture 2. On-line vs. Off-line Algorithms: Competitive Analysis. Move-to-Front List Rearrangement

Beyond Counting. Owen Kaser. September 17, 2014

Week - 03 Lecture - 18 Recursion. For the last lecture of this week, we will look at recursive functions. (Refer Slide Time: 00:05)

lecture notes September 2, How to sort?

Theorem 2.9: nearest addition algorithm

Subset sum problem and dynamic programming

5.6 Rational Equations

CSC 505, Spring 2005 Week 6 Lectures page 1 of 9

The Design of Approximation Algorithms

Lecture: Virtual Memory, DRAM Main Memory. Topics: virtual memory, TLB/cache access, DRAM intro (Sections 2.2)

Lecture 4 Median and Selection

CS2 Algorithms and Data Structures Note 10. Depth-First Search and Topological Sorting

RECURSION. Week 6 Laboratory for Introduction to Programming and Algorithms Uwe R. Zimmer based on material by James Barker. Pre-Laboratory Checklist

Lecture 1 Contracts : Principles of Imperative Computation (Fall 2018) Frank Pfenning

CS261: A Second Course in Algorithms Lecture #16: The Traveling Salesman Problem

CSC236 Week 5. Larry Zhang

Lecture 1 Contracts. 1 A Mysterious Program : Principles of Imperative Computation (Spring 2018) Frank Pfenning

Online Coloring Known Graphs

How invariants help writing loops Author: Sander Kooijmans Document version: 1.0

Recitation 4: Elimination algorithm, reconstituted graph, triangulation

AXIOMS OF AN IMPERATIVE LANGUAGE PARTIAL CORRECTNESS WEAK AND STRONG CONDITIONS. THE AXIOM FOR nop

Treaps. 1 Binary Search Trees (BSTs) CSE341T/CSE549T 11/05/2014. Lecture 19

CS 231: Algorithmic Problem Solving

1 Achieving IND-CPA security

MergeSort, Recurrences, Asymptotic Analysis Scribe: Michael P. Kim Date: April 1, 2015

Information Security

Introduction to Optimization

ISA 562: Information Security, Theory and Practice. Lecture 1

Privacy and Security in Online Social Networks Department of Computer Science and Engineering Indian Institute of Technology, Madras

CMPSCI611: The SUBSET-SUM Problem Lecture 18

COMP260 Spring 2014 Notes: February 4th

CSE 421 Applications of DFS(?) Topological sort

6.001 Notes: Section 4.1

The Hunt-Szymanski Algorithm for LCS

Lecture 8: Summary of Haskell course + Type Level Programming

The Limits of Sorting Divide-and-Conquer Comparison Sorts II

Limitations of Algorithmic Solvability In this Chapter we investigate the power of algorithms to solve problems Some can be solved algorithmically and

Coverage Approximation Algorithms

Greedy Homework Problems

Data Structures and Algorithms Dr. Naveen Garg Department of Computer Science and Engineering Indian Institute of Technology, Delhi.

1 Probability Review. CS 124 Section #8 Hashing, Skip Lists 3/20/17. Expectation (weighted average): the expectation of a random quantity X is:

Geo-Routing. Chapter 2. Ad Hoc and Sensor Networks Roger Wattenhofer

Institut for Matematik & Datalogi November 15, 2010 Syddansk Universitet. DM528: Combinatorics, Probability and Randomized Algorithms Ugeseddel 3

Lecture Notes on Contracts

University of Toronto Mississauga. Flip to the back cover and write down your name and student number.

CSE373 Fall 2013, Second Midterm Examination November 15, 2013

1 More on the Bellman-Ford Algorithm

Online Algorithms with Advice

Page migration in dynamic networks

Integer Multiplication and Division

Greedy algorithms is another useful way for solving optimization problems.

(c) Finally apply critical path scheduling using two processors to the order requirement

a) Alternative Optima, b) Infeasible(or non existing) solution, c) unbounded solution.

(Refer Slide Time: 2:20)

Randomized Algorithms for Online Matching with Two Sources

/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Priority Queues / Heaps Date: 9/27/17

Midterm Exam 2B Answer key

Points covered an odd number of times by translates

Lecture 4: examples of topological spaces, coarser and finer topologies, bases and closed sets

Reliable programming

CPSC 536N: Randomized Algorithms Term 2. Lecture 5

CSC2420 Fall 2012: Algorithm Design, Analysis and Theory

Cryptology complementary. Symmetric modes of operation

Advanced Algorithms. Class Notes for Thursday, September 18, 2014 Bernard Moret

CSC2420: Algorithm Design, Analysis and Theory Fall 2017

Combinatorial Optimization

The implementation is written in Python, instructions on how to run it are given in the last section.

CS 4349 Lecture October 18th, 2017

The hierarchical model for load balancing on two machines

CSCI 1100L: Topics in Computing Lab Lab 1: Introduction to the Lab! Part I

Stanford University CS359G: Graph Partitioning and Expanders Handout 1 Luca Trevisan January 4, 2011

Design and Analysis of Algorithms Prof. Madhavan Mukund Chennai Mathematical Institute. Week 02 Module 06 Lecture - 14 Merge Sort: Analysis

COMP Online Algorithms. Online Graph Problems. Shahin Kamali. Lecture 23 - Nov. 28th, 2017 University of Manitoba

A Guide to Deterministic and Randomized Online Algorithms for the List Access Problem

CS261: Problem Set #1

Transcription:

Department of Mathematics and Computer Science University of Southern Denmark, Odense November 7, 06 KSL Exercises for Week 7 on Online Algorithms a topic in DM5 Introduction to Computer Science Kim Skak Larsen Fall 06 The exercises are of significantly varying difficulty. They are organized in order of topic: ski rental, machine scheduling, and bin packing. Thus, if you find any problem too hard, go to the next topic before you return to the harder problems. A number of extra assignments in different categories are listed at the end. Ski Rental Exercise Prove that no matter which other algorithm than the one from the lecture notes we define for ski rental, the algorithm will perform worse, i.e., the competitive ratio will be strictly higher than 9 0. Start by analyzing the algorithms Buy on day 5 and Buy on day 5 to see what happens. The skis still cost 0 units to buy and unit per day to rent. Exercise Let us consider the smaller variant of the ski rental problem, where skis cost units. Clearly, the best algorithm we can design is Buy on day, which has competitive ratio 7. We introduce a new element into our code: A coin flip! This is known as a randomized algorithm.

Consider the algorithm that rents the first two days, flips a coin on the third day and buys/rents based on that, and buys on the fourth day if it didn t buy already. Obvious worst-case sequences to consider giving our algorithm are and it s a new day, it s a new day, it s a new day, come home it s a new day, it s a new day, it s a new day, it s a new day Separately for each sequence, compute our algorithm s expected cost (the average of the two possibilities resulting from the coin flip on day ), compute OPT s cost, and then the ratio. For which sequence do we get the worst expected cost? (That s the sequence the adversary will give us.) Is that better or worse than the 7 -competitive deterministic algorithm? Exercise Implement the above algorithm in PYTHON and verify your calculations by computing the average cost for each sequence over 000 runs of the algorithm. Coin flips can be implemented like this: from random import random if random() < 0.5: print("head") else: print("tail") Machine Scheduling Exercise For m =, which schedule does the List Scheduling algorithm, LS, produce on the following input sequence:

Exercise 5 In the lecture, we proved that the machine scheduling algorithm, LS, could not perform better than. We now consider only two machines. Thus, m =, m and the ratio is then. Just because LS cannot perform better, it could be that some other algorithm could. Prove (for m = ) that this is not the case. You must design an input, where no algorithm, no matter what decisions it makes, can do better than times OPT. You only need sequences with two and three jobs and a case analysis with only two cases, depending on what an algorithm does with the second job that is given. Bin Packing Exercise 6 Consider the first bin packing example given in the lecture, where the First-Fit algorithm, FF, uses four bins. Show that OPT only needs three. Exercise 7 How does the First-Fit algorithm, FF, behave on the input sequence below? Item sizes are given in multiples of 6.

Exercise 8 Why can the following configuration not have been produced by the bin packing algorithm FF? Item size are given in multiples of 9. 5 Exercise 9 For bin packing, one can prove the upper bound that FF is.7-competitive. However, this is a quite hard proof. In this exercise, we will try to improve (raise) the lower bound. In the lecture, we saw an example demonstrating that FF can be as bad as =.5 times OPT. Let that example inspire you, and try to use items of the following three sizes: 7 + 000, + 000, + 000 Find a sequence where FF performs 5 times worse than OPT. Now try using + 000, 7 + 000, + 000, + 000 to get a lower bound close to the.7 upper bound. Exercise 0 It is very easy to implement FF in PYTHON, if there are no efficiency requirements: just use a list to hold the current level in the bins, and for each item, search

for the first bin with enough space. If you make sure there are enough bins from the beginning, then there are no special cases. And you simple count the number of non-empty bins at the end to get the result. Implement FF. Try to define your own algorithm, from scratch or as a variant of FF. Test your own algorithm up against FF and try to determine which one is best; for instance on uniformly distributed sequences, i.e., each item size is chosen like this: from random import seed, random seed().. item = random() You don t have to use seed; the intention is simply to provide a reproducible random sequence, i.e., seed is called once and the seed value initializes the sequence. Extra Exercises If you extra have time or interest, you can consider the following problems. Exercise [Hard] In the set-up from Exercise, consider choosing what to do on the third day with a probability different from. What is the best probability to choose? What does the expected ratio become? Exercise A core problem for an online machine scheduling algorithm is whether to make a level or a skewed schedule. For instance, just considering m = and the sequences, and,,, we don t know what the best option is for the second job: 5

placing it on the same machine as the first job or not. (Because this depends on the future: do we receive a third job of size or not?) Try to randomize the decision as you did earlier for ski rental. Assuming you get one of these two sequences, can you get an expected ratio smaller than? Exercise Finish left-over discussions from the study group on online algorithms. 6