Matriculation number: You have 90 minutes to complete the exam of InformatikIIb. The following rules apply:

Size: px
Start display at page:

Download "Matriculation number: You have 90 minutes to complete the exam of InformatikIIb. The following rules apply:"

Transcription

1 Departmet of Iformatics Prof. Dr. Michael Böhle Bizmühlestrasse Zurich Phoe: AlgoDat Midterm1 Sprig Name: Matriculatio umber: Advice You have 90 miutes to complete the exam of IformatikIIb. The followig rules apply: Aswer the questios o the exam sheets or the backside. Mark clearly which aswer belogs to which questio. Additioal sheets are provided upo request. If you use additioal sheets, put your ame ad matriculatio umber o each of them. Check the completeess of your exam (1 umbered pages). Use a pe i blue or black colour for your solutios. Pecils ad pes i other colours are ot allowed. Solutios writte i pecil will ot be corrected. Stick to the termiology ad otatios used i the lectures. For the exam Iformatik IIb, oly the followig materials are allowed for the exam: Oe A4 sheet (-sided) with your persoal hadwritte otes, writte by yourself. Sheets that do ot coform to this specificatio will be collected. A foreig laguage dictioary is allowed. The dictioary will be checked by a supervisor. No additioal items are allowed. Notably calculators, computers, pdas, smart-phoes, audio-devices or similar devices may ot be used. Ay cheatig attempt will result i a failed test (meaig 0 poits). Put your studet legitimatio card ( Legi ) o the desk. Sigature: Correctio slot Please do ot fill out the part below Exercise 1 3 Total Poits Achieved Maximum Poits

2 Exercise 1 0 Poits Asymptotic Complexity ad Recurreces 1.1 [4 poits] Calculate the asymptotic tight boud for the followig fuctios ad rak them by their order of growth (lowest first). Clearly work out the calculatio steps i your solutio: f 1 () = lg 8 (3 + 8 lg ), f () = +10, f 3 () = log π log log ( 10 log 35 ), f 4 () = max((log ) 4, ), f 5 () = lg 10, f 6 () = ( + 10)! f 1 () = lg 8 (3 + 8 lg ) Θ( log ) f () = +10 Θ( ) f 3 () = log π log log ( 10 log 35 ) Θ((log ) ) f 4 () = max((log ) 4, ) Θ( ) f 5 () = lg 10 = (10 log ) 16 = (10 ) 4 Θ( 8 ) f 6 () = ( + 10)! Θ(( + 10)!) 1 Rakig: f 3, f 4, f 1, f 5, f, f 6

3 Name: Matriculatio umber: 1. [ poits] Calculate the asymptotic tight boud of the followig recurreces. If the Master Theorem ca be used, write dow a, b, f() ad which case (1-3) applies. a) T () = 7T ( 3 ) a = 7, b = 3, f() = Θ( 3 ), Case : T() = Θ( 3 log 3 ) b) T () = 9T ( ) a = 9, b = 4, f() = 3, Case 3: Θ( 3 ) Regularity coditio: if c = 9, a f(/b) = 9 ( 64 4 )3 9 T () = Θ( 3 )

4 1.3 [6 poits] Cosider the followig recurrece. { T () = a) Compute the value of T () for = 8. 4, if = 1 T (/) , if > 1 T (8) = T (4) = (T () ) + 41 = 4(T (1) ) + 83 = 159 b) Solve recurrece exactly by givig a closed form expressio (without T () o the right side of = ). T () = T ( ) = [T ( ] ) = T ( ) (1 + ) = [ T ( 3 ) ] (1 + ) = 3 T ( 3 ) (1 + + ) =... = i T ( i ) + i 5 + ( i 1 ) For i = lg, we have: T () = lg T ( lg ) + lg 5 + ( lg 1 ) = T (1) + 5lg + lg 1 = 5lg c) Fid the simplest f(), such that T () = Θ(f()). f() = lg 4

5 Name: Matriculatio umber: 1.4 [8 poits] Cosider the followig recurrece: { 1, if = 1 T () = T (/5) + T (7/10) +, if > 1 a) Draw a recursio tree ad use it to estimate the asymptotic upper boud of T (). Iclude the tree-based calculatios that led to your estimate. = h = log = 9 10 = Logest brach o the left. Tree grows util ( 7 h 10) = 1 = h = log 10 7 Guess: O() b) Prove the correctess of your estimate usig iductio. Proof by iductio: T () = T (/5) + T (7/10) + (recurrece) c + c 7 + (iductive hyp.) 5 10 = c( 9) + (reformattig) 10 = ( 9c + 1) (reformattig) 10 c (for c 10, > 1) 5

6 Exercise 0 Poits Rutime ad Recursio Algorithm: alg(a,) 1 for i = 1 to / do mi = i; 3 max = i + 1; 4 if A[mi] > A[max] the 5 exchage A[mi] ad A[max]; 6 for j = i + 1 to i do 7 if A[j] < A[mi] the 8 mi = j; 9 if A[j] > A[max] the 10 max = j; 11 exchage A[i] ad A[mi]; 1 exchage A[ i + 1] ad A[max];.1 [ poits] The algorithm alg(a,) gets as iputs a array A[1...] ad the umber of itegers it cotais. Assume A=[5, 7, 6, 3,, 1, 4]. Complete the followig matrix where you eed to show the value of i ad the cotet of A after each executio of the outer for loop. The first lie of the matrix shows the iitial array A before the executio of the loop. i A[1] A[] A[3] A[4] A[5] A[6] A[7]

7 Name: Matriculatio umber:. [ poits] Describe i words (maximum three lies) what the algorithm alg(a,) does. The algorithm sorts the array. It is a variat of selectio sort. I every pass it fids both the miimum ad maximum values ad creates two sorted partitios of the array, oe with miimum values (o the left side) ad oe with maximum (o the right side). This reduces the umber of scas of the list by a factor of, elimiatig some loop overhead but ot actually decreasig the umber of comparisos or swaps. 7

8 .3 [8 poits] Aalyze the steps of the algorithm alg(a,), calculate its exact rutime ad its asymptotic complexity. lie 1 c lie c lie 3 c 3 lie 4 c 4 lie 5 c 5 α 1 lie 6 c ( ) + lie 7 c ( ) lie 8 c 8 α 1 4 ( ) lie 9 c ( ) lie 10 c 10 α3 1 4 ( ) lie 11 c 11 lie 1 c 1 * 0 α 1 1 ** For each i [1, ], it will ru ( i) (i + 1) + 1 times plus termiatio coditio check. *** ( i) = 1 4 ( ) i=1 **** 0 α 1, 0 α 3 1, α + α 3 1, Ruig time: times for 8

9 Name: Matriculatio umber: T () = c 1 + (c 1 + c + c 3 + c 4 + α 1 c 5 + c 6 + c 11 + c 1 ) ( )(c 7 + α c 8 + c 9 + α 3 c 10 ) = (c 7 + α c 8 + c 9 + α 3 c 10 ) + (c 1 + c + c 3 + c 4 + α 1 c 5 + c 6 + c 11 + c 1 c 7 α c 8 c 9 α 3 c 10 ) + c 1 O( ).4 [8 poits] Give a recursive versio of the algorithm alg(a,). Use either C or pseudocode for your solutio. Algorithm: BidirectioSelectioSortRec(A, l, r) 1 if l r the mi = l; 3 max = r; 4 if A[mi] > A[max] the 5 exchage A[mi] ad A[max]; 6 for j = l + 1 to r 1 do 7 if A[j] < A[mi] the 8 mi = j; 9 if A[j] > A[max] the 10 max = j; 11 exchage A[l] ad A[mi]; 1 exchage A[r] ad A[max]; 13 BidirectioSelectioSortRec(A, l + 1, r 1); 14 Call: BidirectioSelectioSortRec(A, 1, ); 9

10 Exercise 3 0 Poits Divide ad Coquer The mi-max search algorithm determies the miimum ad maximum elemets of a usorted array A[1...]. First, it divides the iput array ito two equal partitios: I (A[1]... A[mid]) ad II (A[mid + 1]... A[]). Afterwards, it calls itself recursively o both partitios to fid the miimum ad the maximum of each partitio, the combies them to fid the global miimum ad maximum elemets. For example, if the give array is [-, -5, 6, -, -3, 1, 5], the the miimum is 5 ad the maximum is [4 poits] Based o the above, draw a tree to illustrate the process of determiig the miimum ad the maximum of the array A = [-, -5, 6, -, -3, 1, 5]. Aotate each ode of the tree with its miimum ad maximum mi =, max = mi = 5, max = 6 mi = 3, max = mi = 1, max = mi = 5, max = 6 mi = 3, max = mi = 5, max =

11 Name: Matriculatio umber: 3. [10 poits] Desig a divide ad coquer algorithm which fids ad returs the miimum ad maximum elemets of a usorted array. Use either C or pseudocode for your solutio. Algorithm: MiMax(A,l,r) 1 if l = r the retur A[l], A[l]; 3 else 4 m = l+r ; 5 mi1, max1 = MiMax(A, l, m); 6 mi, max = MiMax(A, m+1, r); 7 if mi1 < mi the 8 mi = mi1; 9 else 10 mi = mi; 11 if max1 > max the 1 max = max1; 13 else 14 max = max; 15 retur mi, max; 3.3 [6 poits] Write the recurrece for the complexity of your algorithm i Task 3.. Solve the recurrece usig the repeated substitutio method. { T () = 0, if = 1 T ( ) + 1, if > 1 T () = T (/) + 1 = (T (/4) + 1) + 1 = 4T (/4) + 3 = 4(T (/8) + 1) + 3 = 8T (/8) + 7 T () = i T (/ i ) + i 1 = lg T (/ lg ) + lg 1 = T (1) + 1 = Θ() 11

12 1

Department of Informatics Prof. Dr. Michael Böhlen Binzmühlestrasse Zurich Phone:

Department of Informatics Prof. Dr. Michael Böhlen Binzmühlestrasse Zurich Phone: Departmet of Iformatics Prof. Dr. Michael Böhle Bizmühlestrasse 14 8050 Zurich Phoe: +41 44 635 4333 Email: boehle@ifi.uzh.ch Iformatik II Midterm1 Sprig 018 3.03.018 Advice You have 90 miutes to complete

More information

COMP285 Midterm Exam Department of Mathematics

COMP285 Midterm Exam Department of Mathematics COMP85 Midterm Exam Departmet of Mathematics Fall 010/011 - November 8, 010 Name: Studet Number: Please fiish withi 90 miutes. All poits above 100 are cosidered as bous poit. You ca reach maximal 1 poits.

More information

Test One (Answer Key)

Test One (Answer Key) CS395/Ma395 (Sprig 2005) Test Oe Name: Page 1 Test Oe (Aswer Key) CS395/Ma395: Aalysis of Algorithms This is a closed book, closed otes, 70 miute examiatio. It is worth 100 poits. There are twelve (12)

More information

CS / MCS 401 Homework 3 grader solutions

CS / MCS 401 Homework 3 grader solutions CS / MCS 401 Homework 3 grader solutios assigmet due July 6, 016 writte by Jāis Lazovskis maximum poits: 33 Some questios from CLRS. Questios marked with a asterisk were ot graded. 1 Use the defiitio of

More information

CS583 Lecture 02. Jana Kosecka. some materials here are based on E. Demaine, D. Luebke slides

CS583 Lecture 02. Jana Kosecka. some materials here are based on E. Demaine, D. Luebke slides CS583 Lecture 02 Jaa Kosecka some materials here are based o E. Demaie, D. Luebke slides Previously Sample algorithms Exact ruig time, pseudo-code Approximate ruig time Worst case aalysis Best case aalysis

More information

CS 270 Algorithms. Oliver Kullmann. Growth of Functions. Divide-and- Conquer Min-Max- Problem. Tutorial. Reading from CLRS for week 2

CS 270 Algorithms. Oliver Kullmann. Growth of Functions. Divide-and- Conquer Min-Max- Problem. Tutorial. Reading from CLRS for week 2 Geeral remarks Week 2 1 Divide ad First we cosider a importat tool for the aalysis of algorithms: Big-Oh. The we itroduce a importat algorithmic paradigm:. We coclude by presetig ad aalysig two examples.

More information

Model of Computation and Runtime Analysis

Model of Computation and Runtime Analysis Model of Computatio ad Rutime Aalysis Model of Computatio Model of Computatio Specifies Set of operatios Cost of operatios (ot ecessarily time) Examples Turig Machie Radom Access Machie (RAM) PRAM Map

More information

Data Structures Lecture 9

Data Structures Lecture 9 Fall 2017 Fag Yu Software Security Lab. Dept. Maagemet Iformatio Systems, Natioal Chegchi Uiversity Data Structures Lecture 9 Midterm o Dec. 7 (9:10-12:00am, 106) Lec 1-9, TextBook Ch1-8, 11,12 How to

More information

This Lecture. Divide and Conquer. Merge Sort: Algorithm. Merge Sort Algorithm. MergeSort (Example) - 1. MergeSort (Example) - 2

This Lecture. Divide and Conquer. Merge Sort: Algorithm. Merge Sort Algorithm. MergeSort (Example) - 1. MergeSort (Example) - 2 This Lecture Divide-ad-coquer techique for algorithm desig. Example the merge sort. Writig ad solvig recurreces Divide ad Coquer Divide-ad-coquer method for algorithm desig: Divide: If the iput size is

More information

Model of Computation and Runtime Analysis

Model of Computation and Runtime Analysis Model of Computatio ad Rutime Aalysis Model of Computatio Model of Computatio Specifies Set of operatios Cost of operatios (ot ecessarily time) Examples Turig Machie Radom Access Machie (RAM) PRAM Map

More information

Analysis of Algorithms -Quicksort-

Analysis of Algorithms -Quicksort- Aalysis of Algorithms -- Adreas Ermedahl MRTC (Mälardales Real-Time Research Ceter) adreas.ermedahl@mdh.se Autum 2004 Proposed by C.A.R. Hoare i 962 Worst- case ruig time: Θ( 2 ) Expected ruig time: Θ(

More information

Divide & Conquer. Divide-and-conquer algorithms. Conventional product of polynomials. Conventional product of polynomials.

Divide & Conquer. Divide-and-conquer algorithms. Conventional product of polynomials. Conventional product of polynomials. Divide-ad-coquer algorithms Divide & Coquer Strategy: Divide the problem ito smaller subproblems of the same type of problem Solve the subproblems recursively Combie the aswers to solve the origial problem

More information

CS 332: Algorithms. Linear-Time Sorting. Order statistics. Slide credit: David Luebke (Virginia)

CS 332: Algorithms. Linear-Time Sorting. Order statistics. Slide credit: David Luebke (Virginia) 1 CS 332: Algorithms Liear-Time Sortig. Order statistics. Slide credit: David Luebke (Virgiia) Quicksort: Partitio I Words Partitio(A, p, r): Select a elemet to act as the pivot (which?) Grow two regios,

More information

Problem Set 1 Solutions

Problem Set 1 Solutions V R N N N R f ] R S Itroductio to Algorithms September 12, 2003 Massachusetts Istitute of echology 6046J/18410J rofessors Shafi Goldwasser ad Silvio Micali Hadout 7 roblem Set 1 Solutios roblem 1-1 Recurrece

More information

Analysis of Algorithms. Introduction. Contents

Analysis of Algorithms. Introduction. Contents Itroductio The focus of this module is mathematical aspects of algorithms. Our mai focus is aalysis of algorithms, which meas evaluatig efficiecy of algorithms by aalytical ad mathematical methods. We

More information

Fundamental Algorithms

Fundamental Algorithms Fudametal Algorithms Chapter 2b: Recurreces Michael Bader Witer 2014/15 Chapter 2b: Recurreces, Witer 2014/15 1 Recurreces Defiitio A recurrece is a (i-equality that defies (or characterizes a fuctio i

More information

Data Structures and Algorithm. Xiaoqing Zheng

Data Structures and Algorithm. Xiaoqing Zheng Data Structures ad Algorithm Xiaoqig Zheg zhegxq@fudaeduc What are algorithms? A sequece of computatioal steps that trasform the iput ito the output Sortig problem: Iput: A sequece of umbers

More information

Algorithms and Data Structures Lecture IV

Algorithms and Data Structures Lecture IV Algorithms ad Data Structures Lecture IV Simoas Šalteis Aalborg Uiversity simas@cs.auc.dk September 5, 00 1 This Lecture Aalyzig the ruig time of recursive algorithms (such as divide-ad-coquer) Writig

More information

COMP26120: More on the Complexity of Recursive Programs (2018/19) Lucas Cordeiro

COMP26120: More on the Complexity of Recursive Programs (2018/19) Lucas Cordeiro COMP26120: More o the Complexity of Recursive Programs (2018/19) Lucas Cordeiro lucas.cordeiro@machester.ac.uk Divide-ad-Coquer (Recurrece) Textbook: Algorithm Desig ad Applicatios, Goodrich, Michael T.

More information

Classification of problem & problem solving strategies. classification of time complexities (linear, logarithmic etc)

Classification of problem & problem solving strategies. classification of time complexities (linear, logarithmic etc) Classificatio of problem & problem solvig strategies classificatio of time complexities (liear, arithmic etc) Problem subdivisio Divide ad Coquer strategy. Asymptotic otatios, lower boud ad upper boud:

More information

A recurrence equation is just a recursive function definition. It defines a function at one input in terms of its value on smaller inputs.

A recurrence equation is just a recursive function definition. It defines a function at one input in terms of its value on smaller inputs. CS23 Algorithms Hadout #6 Prof Ly Turbak September 8, 200 Wellesley College RECURRENCES This hadout summarizes highlights of CLRS Chapter 4 ad Appedix A (CLR Chapters 3 & 4) Two-Step Strategy for Aalyzig

More information

CSI 2101 Discrete Structures Winter Homework Assignment #4 (100 points, weight 5%) Due: Thursday, April 5, at 1:00pm (in lecture)

CSI 2101 Discrete Structures Winter Homework Assignment #4 (100 points, weight 5%) Due: Thursday, April 5, at 1:00pm (in lecture) CSI 101 Discrete Structures Witer 01 Prof. Lucia Moura Uiversity of Ottawa Homework Assigmet #4 (100 poits, weight %) Due: Thursday, April, at 1:00pm (i lecture) Program verificatio, Recurrece Relatios

More information

Spring 2016 Exam 2 NAME: PIN:

Spring 2016 Exam 2 NAME: PIN: MARK BOX problem poits 0 20 20 2 0 3 0 4-7 20 NAME: PIN: 8 0 9 0 % 00 INSTRUCTIONS O Problem 0, fill i the blaks. As you kow, if you do ot make at least half of the poits o Problem 0, the your score for

More information

ITEC 360 Data Structures and Analysis of Algorithms Spring for n 1

ITEC 360 Data Structures and Analysis of Algorithms Spring for n 1 ITEC 360 Data Structures ad Aalysis of Algorithms Sprig 006 1. Prove that f () = 60 + 5 + 1 is Θ ( ). 60 + 5 + 1 60 + 5 + = 66 for 1 Take C 1 = 66 f () = 60 + 5 + 1 is O( ) Sice 60 + 5 + 1 60 for 1 If

More information

4.3 Growth Rates of Solutions to Recurrences

4.3 Growth Rates of Solutions to Recurrences 4.3. GROWTH RATES OF SOLUTIONS TO RECURRENCES 81 4.3 Growth Rates of Solutios to Recurreces 4.3.1 Divide ad Coquer Algorithms Oe of the most basic ad powerful algorithmic techiques is divide ad coquer.

More information

CS 332: Algorithms. Quicksort

CS 332: Algorithms. Quicksort CS 33: Aorithms Quicsort David Luebe //03 Homewor Assiged today, due ext Wedesday Will be o web page shortly after class Go over ow David Luebe //03 Review: Quicsort Sorts i place Sorts O( ) i the average

More information

Examples: data compression, path-finding, game-playing, scheduling, bin packing

Examples: data compression, path-finding, game-playing, scheduling, bin packing Algorithms - Basic Cocepts Algorithms so what is a algorithm, ayway? The dictioary defiitio: A algorithm is a well-defied computatioal procedure that takes iput ad produces output. This class will deal

More information

Fall 2018 Exam 2 PIN: 17 INSTRUCTIONS

Fall 2018 Exam 2 PIN: 17 INSTRUCTIONS MARK BOX problem poits 0 0 HAND IN PART 0 3 0 NAME: Solutios 4 0 0 PIN: 6-3x % 00 INSTRUCTIONS This exam comes i two parts. () HAND IN PART. Had i oly this part. () STATEMENT OF MULTIPLE CHOICE PROBLEMS.

More information

Design and Analysis of Algorithms

Design and Analysis of Algorithms Desig ad Aalysis of Algorithms CSE 53 Lecture 9 Media ad Order Statistics Juzhou Huag, Ph.D. Departmet of Computer Sciece ad Egieerig Dept. CSE, UT Arligto CSE53 Desig ad Aalysis of Algorithms Medias ad

More information

Recursive Algorithms. Recurrences. Recursive Algorithms Analysis

Recursive Algorithms. Recurrences. Recursive Algorithms Analysis Recursive Algorithms Recurreces Computer Sciece & Egieerig 35: Discrete Mathematics Christopher M Bourke cbourke@cseuledu A recursive algorithm is oe i which objects are defied i terms of other objects

More information

CSI 5163 (95.573) ALGORITHM ANALYSIS AND DESIGN

CSI 5163 (95.573) ALGORITHM ANALYSIS AND DESIGN CSI 5163 (95.573) ALGORITHM ANALYSIS AND DESIGN CSI 5163 (95.5703) ALGORITHM ANALYSIS AND DESIGN (3 cr.) (T) Topics of curret iterest i the desig ad aalysis of computer algorithms for graphtheoretical

More information

Introduction to Algorithms 6.046J/18.401J LECTURE 3 Divide and conquer Binary search Powering a number Fibonacci numbers Matrix multiplication

Introduction to Algorithms 6.046J/18.401J LECTURE 3 Divide and conquer Binary search Powering a number Fibonacci numbers Matrix multiplication Itroductio to Algorithms 6.046J/8.40J LECTURE 3 Divide ad coquer Biary search Powerig a umber Fiboacci umbers Matrix multiplicatio Strasse s algorithm VLSI tree layout Prof. Charles E. Leiserso The divide-ad-coquer

More information

Midterm Exam #2. Please staple this cover and honor pledge atop your solutions.

Midterm Exam #2. Please staple this cover and honor pledge atop your solutions. Math 50B Itegral Calculus April, 07 Midterm Exam # Name: Aswer Key David Arold Istructios. (00 poits) This exam is ope otes, ope book. This icludes ay supplemetary texts or olie documets. You are ot allowed

More information

Sorting Algorithms. Algorithms Kyuseok Shim SoEECS, SNU.

Sorting Algorithms. Algorithms Kyuseok Shim SoEECS, SNU. Sortig Algorithms Algorithms Kyuseo Shim SoEECS, SNU. Desigig Algorithms Icremetal approaches Divide-ad-Coquer approaches Dyamic programmig approaches Greedy approaches Radomized approaches You are ot

More information

Recurrence Relations

Recurrence Relations Recurrece Relatios Aalysis of recursive algorithms, such as: it factorial (it ) { if (==0) retur ; else retur ( * factorial(-)); } Let t be the umber of multiplicatios eeded to calculate factorial(). The

More information

Chapter 22 Developing Efficient Algorithms

Chapter 22 Developing Efficient Algorithms Chapter Developig Efficiet Algorithms 1 Executig Time Suppose two algorithms perform the same task such as search (liear search vs. biary search). Which oe is better? Oe possible approach to aswer this

More information

Lecture 3: Asymptotic Analysis + Recurrences

Lecture 3: Asymptotic Analysis + Recurrences Lecture 3: Asymptotic Aalysis + Recurreces Data Structures ad Algorithms CSE 373 SU 18 BEN JONES 1 Warmup Write a model ad fid Big-O for (it i = 0; i < ; i++) { for (it j = 0; j < i; j++) { System.out.pritl(

More information

10.1 Sequences. n term. We will deal a. a n or a n n. ( 1) n ( 1) n 1 2 ( 1) a =, 0 0,,,,, ln n. n an 2. n term.

10.1 Sequences. n term. We will deal a. a n or a n n. ( 1) n ( 1) n 1 2 ( 1) a =, 0 0,,,,, ln n. n an 2. n term. 0. Sequeces A sequece is a list of umbers writte i a defiite order: a, a,, a, a is called the first term, a is the secod term, ad i geeral eclusively with ifiite sequeces ad so each term Notatio: the sequece

More information

Similar idea to multiplication in N, C. Divide and conquer approach provides unexpected improvements. Naïve matrix multiplication

Similar idea to multiplication in N, C. Divide and conquer approach provides unexpected improvements. Naïve matrix multiplication Next. Covered bsics of simple desig techique (Divided-coquer) Ch. of the text.. Next, Strsse s lgorithm. Lter: more desig d coquer lgorithms: MergeSort. Solvig recurreces d the Mster Theorem. Similr ide

More information

Mathematical Foundation. CSE 6331 Algorithms Steve Lai

Mathematical Foundation. CSE 6331 Algorithms Steve Lai Mathematical Foudatio CSE 6331 Algorithms Steve Lai Complexity of Algorithms Aalysis of algorithm: to predict the ruig time required by a algorithm. Elemetary operatios: arithmetic & boolea operatios:

More information

CS:3330 (Prof. Pemmaraju ): Assignment #1 Solutions. (b) For n = 3, we will have 3 men and 3 women with preferences as follows: m 1 : w 3 > w 1 > w 2

CS:3330 (Prof. Pemmaraju ): Assignment #1 Solutions. (b) For n = 3, we will have 3 men and 3 women with preferences as follows: m 1 : w 3 > w 1 > w 2 Shiyao Wag CS:3330 (Prof. Pemmaraju ): Assigmet #1 Solutios Problem 1 (a) Cosider iput with me m 1, m,..., m ad wome w 1, w,..., w with the followig prefereces: All me have the same prefereces for wome:

More information

Fall 2018 Exam 3 HAND IN PART 0 10 PIN: 17 INSTRUCTIONS

Fall 2018 Exam 3 HAND IN PART 0 10 PIN: 17 INSTRUCTIONS MARK BOX problem poits HAND IN PART 0 10 1 10 2 5 NAME: Solutios 3 10 PIN: 17 4 16 65=13x5 % 100 INSTRUCTIONS This exam comes i two parts. (1) HAND IN PART. Had i oly this part. (2) STATEMENT OF MULTIPLE

More information

A B = φ No conclusion. 2. (5) List the values of the sets below. Let A = {n 2 : n P n 5} = {1,4,9,16,25} and B = {n 4 : n P n 5} = {1,16,81,256,625}

A B = φ No conclusion. 2. (5) List the values of the sets below. Let A = {n 2 : n P n 5} = {1,4,9,16,25} and B = {n 4 : n P n 5} = {1,16,81,256,625} CPSC 070 Aswer Keys Test # October 1, 014 1. (a) (5) Defie (A B) to be those elemets i set A but ot i set B. Use set membership tables to determie what elemets are cotaied i (A (B A)). Use set membership

More information

Math 116 Practice for Exam 3

Math 116 Practice for Exam 3 Math 6 Practice for Exam Geerated October 0, 207 Name: SOLUTIONS Istructor: Sectio Number:. This exam has 7 questios. Note that the problems are ot of equal difficulty, so you may wat to skip over ad retur

More information

CIS 121 Data Structures and Algorithms with Java Spring Code Snippets and Recurrences Monday, February 4/Tuesday, February 5

CIS 121 Data Structures and Algorithms with Java Spring Code Snippets and Recurrences Monday, February 4/Tuesday, February 5 CIS 11 Data Structures ad Algorithms with Java Sprig 019 Code Sippets ad Recurreces Moday, February 4/Tuesday, February 5 Learig Goals Practice provig asymptotic bouds with code sippets Practice solvig

More information

CSE 1400 Applied Discrete Mathematics Number Theory and Proofs

CSE 1400 Applied Discrete Mathematics Number Theory and Proofs CSE 1400 Applied Discrete Mathematics Number Theory ad Proofs Departmet of Computer Scieces College of Egieerig Florida Tech Sprig 01 Problems for Number Theory Backgroud Number theory is the brach of

More information

SCORE. Exam 2. MA 114 Exam 2 Fall 2017

SCORE. Exam 2. MA 114 Exam 2 Fall 2017 Exam Name: Sectio ad/or TA: Do ot remove this aswer page you will retur the whole exam. You will be allowed two hours to complete this test. No books or otes may be used. You may use a graphig calculator

More information

Algorithms Design & Analysis. Divide & Conquer

Algorithms Design & Analysis. Divide & Conquer Algorithms Desig & Aalysis Divide & Coquer Recap Direct-accessible table Hash tables Hash fuctios Uiversal hashig Perfect Hashig Ope addressig 2 Today s topics The divide-ad-coquer desig paradigm Revised

More information

Ch3. Asymptotic Notation

Ch3. Asymptotic Notation Ch. Asymptotic Notatio copyright 006 Preview of Chapters Chapter How to aalyze the space ad time complexities of program Chapter Review asymptotic otatios such as O, Ω, Θ, o for simplifyig the aalysis

More information

Lecture 7: Solving Recurrences

Lecture 7: Solving Recurrences Lecture 7: Solvig Recurreces CSE 7: Data Structures ad Algorithms CSE 7 19 WI KASEY CHAMPION 1 Warm Up Writig Recurreces CSE 7 19 WI KASEY CHAMPION 2 Admiistriva HW 2 Part 1 due Friday git ruers will get

More information

CATHOLIC JUNIOR COLLEGE General Certificate of Education Advanced Level Higher 2 JC2 Preliminary Examination MATHEMATICS 9740/01

CATHOLIC JUNIOR COLLEGE General Certificate of Education Advanced Level Higher 2 JC2 Preliminary Examination MATHEMATICS 9740/01 CATHOLIC JUNIOR COLLEGE Geeral Certificate of Educatio Advaced Level Higher JC Prelimiary Examiatio MATHEMATICS 9740/0 Paper 4 Aug 06 hours Additioal Materials: List of Formulae (MF5) Name: Class: READ

More information

CSE 4095/5095 Topics in Big Data Analytics Spring 2017; Homework 1 Solutions

CSE 4095/5095 Topics in Big Data Analytics Spring 2017; Homework 1 Solutions CSE 09/09 Topics i ig Data Aalytics Sprig 2017; Homework 1 Solutios Note: Solutios to problems,, ad 6 are due to Marius Nicolae. 1. Cosider the followig algorithm: for i := 1 to α log e do Pick a radom

More information

Math 155 (Lecture 3)

Math 155 (Lecture 3) Math 55 (Lecture 3) September 8, I this lecture, we ll cosider the aswer to oe of the most basic coutig problems i combiatorics Questio How may ways are there to choose a -elemet subset of the set {,,,

More information

Solutions for the Exam 9 January 2012

Solutions for the Exam 9 January 2012 Mastermath ad LNMB Course: Discrete Optimizatio Solutios for the Exam 9 Jauary 2012 Utrecht Uiversity, Educatorium, 15:15 18:15 The examiatio lasts 3 hours. Gradig will be doe before Jauary 23, 2012. Studets

More information

Math 116 Practice for Exam 3

Math 116 Practice for Exam 3 Math 6 Practice for Eam 3 Geerated April 4, 26 Name: SOLUTIONS Istructor: Sectio Number:. This eam has questios. Note that the problems are ot of equal difficulty, so you may wat to skip over ad retur

More information

Annotations to the assignments and the solution sheet. Note the following points

Annotations to the assignments and the solution sheet. Note the following points WS 26/7 Trial Exam: Fudametals of Computer Egieerig Seite: Aotatios to the assigmets ad the solutio sheet This is a multiple choice examiatio, that meas: Solutio approaches are ot assessed. For each sub-task

More information

w (1) ˆx w (1) x (1) /ρ and w (2) ˆx w (2) x (2) /ρ.

w (1) ˆx w (1) x (1) /ρ and w (2) ˆx w (2) x (2) /ρ. 2 5. Weighted umber of late jobs 5.1. Release dates ad due dates: maximimizig the weight of o-time jobs Oce we add release dates, miimizig the umber of late jobs becomes a sigificatly harder problem. For

More information

Advanced Course of Algorithm Design and Analysis

Advanced Course of Algorithm Design and Analysis Differet complexity measures Advaced Course of Algorithm Desig ad Aalysis Asymptotic complexity Big-Oh otatio Properties of O otatio Aalysis of simple algorithms A algorithm may may have differet executio

More information

Chapter 2. Asymptotic Notation

Chapter 2. Asymptotic Notation Asyptotic Notatio 3 Chapter Asyptotic Notatio Goal : To siplify the aalysis of ruig tie by gettig rid of details which ay be affected by specific ipleetatio ad hardware. [1] The Big Oh (O-Notatio) : It

More information

Merge Sort. Outline and Reading. Divide-and-Conquer. Divide-and-conquer paradigm ( 4.1.1) Merge-sort ( 4.1.1)

Merge Sort. Outline and Reading. Divide-and-Conquer. Divide-and-conquer paradigm ( 4.1.1) Merge-sort ( 4.1.1) Merge Sort 7 2 9 4 2 4 7 9 7 2 2 7 9 4 4 9 7 7 2 2 9 9 4 4 Merge Sort versio 1.3 1 Outlie d Redig Divide-d-coquer prdigm ( 4.1.1 Merge-sort ( 4.1.1 Algorithm Mergig two sorted sequeces Merge-sort tree

More information

MTH 133 Solutions to Exam 2 Nov. 18th 2015

MTH 133 Solutions to Exam 2 Nov. 18th 2015 Name: Sectio: Recitatio Istructor: READ THE FOLLOWING INSTRUCTIONS. Do ot ope your exam util told to do so. No calculators, cell phoes or ay other electroic devices ca be used o this exam. Clear your desk

More information

Mathematics review for CSCI 303 Spring Department of Computer Science College of William & Mary Robert Michael Lewis

Mathematics review for CSCI 303 Spring Department of Computer Science College of William & Mary Robert Michael Lewis Mathematics review for CSCI 303 Sprig 019 Departmet of Computer Sciece College of William & Mary Robert Michael Lewis Copyright 018 019 Robert Michael Lewis Versio geerated: 13 : 00 Jauary 17, 019 Cotets

More information

Fall 2016 Exam 2 PIN: 17

Fall 2016 Exam 2 PIN: 17 MARK BOX problem poits 0 0 0 2-3 60=2x5 4 0 5 0 % 00 HAND IN PART NAME: Solutios PIN: 7 INSTRUCTIONS This exam comes i two parts. () HAND IN PART. Had i oly this part. (2) STATEMENT OF MULTIPLE CHOICE

More information

CSE 5311 Notes 1: Mathematical Preliminaries

CSE 5311 Notes 1: Mathematical Preliminaries Chapter 1 - Algorithms Computig CSE 5311 Notes 1: Mathematical Prelimiaries Last updated 1/20/18 12:56 PM) Relatioship betwee complexity classes, eg log,, log, 2, 2, etc Chapter 2 - Gettig Started Loop

More information

CS161: Algorithm Design and Analysis Handout #10 Stanford University Wednesday, 10 February 2016

CS161: Algorithm Design and Analysis Handout #10 Stanford University Wednesday, 10 February 2016 CS161: Algorithm Desig ad Aalysis Hadout #10 Staford Uiversity Wedesday, 10 February 2016 Lecture #11: Wedesday, 10 February 2016 Topics: Example midterm problems ad solutios from a log time ago Sprig

More information

SCORE. Exam 2. MA 114 Exam 2 Fall 2016

SCORE. Exam 2. MA 114 Exam 2 Fall 2016 MA 4 Exam Fall 06 Exam Name: Sectio ad/or TA: Do ot remove this aswer page you will retur the whole exam. You will be allowed two hours to complete this test. No books or otes may be used. You may use

More information

Data Structures and Algorithms

Data Structures and Algorithms Data Structures ad Algorithms Autum 2017-2018 Outlie 1 Sortig Algorithms (cotd) Outlie Sortig Algorithms (cotd) 1 Sortig Algorithms (cotd) Heapsort Sortig Algorithms (cotd) Have see that we ca build a

More information

Recursive Algorithm for Generating Partitions of an Integer. 1 Preliminary

Recursive Algorithm for Generating Partitions of an Integer. 1 Preliminary Recursive Algorithm for Geeratig Partitios of a Iteger Sug-Hyuk Cha Computer Sciece Departmet, Pace Uiversity 1 Pace Plaza, New York, NY 10038 USA scha@pace.edu Abstract. This article first reviews the

More information

Skip Lists. Presentation for use with the textbook, Algorithm Design and Applications, by M. T. Goodrich and R. Tamassia, Wiley, 2015 S 3 S S 1

Skip Lists. Presentation for use with the textbook, Algorithm Design and Applications, by M. T. Goodrich and R. Tamassia, Wiley, 2015 S 3 S S 1 Presetatio for use with the textbook, Algorithm Desig ad Applicatios, by M. T. Goodrich ad R. Tamassia, Wiley, 2015 Skip Lists S 3 15 15 23 10 15 23 36 Skip Lists 1 What is a Skip List A skip list for

More information

1 Generating functions for balls in boxes

1 Generating functions for balls in boxes Math 566 Fall 05 Some otes o geeratig fuctios Give a sequece a 0, a, a,..., a,..., a geeratig fuctio some way of represetig the sequece as a fuctio. There are may ways to do this, with the most commo ways

More information

OPTIMAL ALGORITHMS -- SUPPLEMENTAL NOTES

OPTIMAL ALGORITHMS -- SUPPLEMENTAL NOTES OPTIMAL ALGORITHMS -- SUPPLEMENTAL NOTES Peter M. Maurer Why Hashig is θ(). As i biary search, hashig assumes that keys are stored i a array which is idexed by a iteger. However, hashig attempts to bypass

More information

Dynamic Programming. Sequence Of Decisions

Dynamic Programming. Sequence Of Decisions Dyamic Programmig Sequece of decisios. Problem state. Priciple of optimality. Dyamic Programmig Recurrece Equatios. Solutio of recurrece equatios. Sequece Of Decisios As i the greedy method, the solutio

More information

Dynamic Programming. Sequence Of Decisions. 0/1 Knapsack Problem. Sequence Of Decisions

Dynamic Programming. Sequence Of Decisions. 0/1 Knapsack Problem. Sequence Of Decisions Dyamic Programmig Sequece Of Decisios Sequece of decisios. Problem state. Priciple of optimality. Dyamic Programmig Recurrece Equatios. Solutio of recurrece equatios. As i the greedy method, the solutio

More information

Divide and Conquer II

Divide and Conquer II Algorithms Divide ad Coquer II Divide ad Coquer II Desig ad Aalsis of Algorithms Adrei Bulatov Algorithms Divide ad Coquer II 6- Closest Pair: The Problem The Closest Pair Problem Istace: poits i the plae

More information

Sequences, Mathematical Induction, and Recursion. CSE 2353 Discrete Computational Structures Spring 2018

Sequences, Mathematical Induction, and Recursion. CSE 2353 Discrete Computational Structures Spring 2018 CSE 353 Discrete Computatioal Structures Sprig 08 Sequeces, Mathematical Iductio, ad Recursio (Chapter 5, Epp) Note: some course slides adopted from publisher-provided material Overview May mathematical

More information

4.1 Sigma Notation and Riemann Sums

4.1 Sigma Notation and Riemann Sums 0 the itegral. Sigma Notatio ad Riema Sums Oe strategy for calculatig the area of a regio is to cut the regio ito simple shapes, calculate the area of each simple shape, ad the add these smaller areas

More information

Please do NOT write in this box. Multiple Choice. Total

Please do NOT write in this box. Multiple Choice. Total Istructor: Math 0560, Worksheet Alteratig Series Jauary, 3000 For realistic exam practice solve these problems without lookig at your book ad without usig a calculator. Multiple choice questios should

More information

WRITTEN ASSIGNMENT 1 ANSWER KEY

WRITTEN ASSIGNMENT 1 ANSWER KEY CISC 65 Itrodutio Desig ad Aalysis of Algorithms WRITTEN ASSIGNMENT ANSWER KEY. Problem -) I geeral, this problem requires f() = some time period be solve for a value. This a be doe for all ase expet lg

More information

4.1 SIGMA NOTATION AND RIEMANN SUMS

4.1 SIGMA NOTATION AND RIEMANN SUMS .1 Sigma Notatio ad Riema Sums Cotemporary Calculus 1.1 SIGMA NOTATION AND RIEMANN SUMS Oe strategy for calculatig the area of a regio is to cut the regio ito simple shapes, calculate the area of each

More information

MATH 166 TEST 3 REVIEW SHEET

MATH 166 TEST 3 REVIEW SHEET MATH 66 TEST REVIEW SHEET Geeral Commets ad Advice: The studet should regard this review sheet oly as a sample of potetial test problems, ad ot a ed-all-be-all guide to its cotet. Aythig ad everythig which

More information

Math 132, Fall 2009 Exam 2: Solutions

Math 132, Fall 2009 Exam 2: Solutions Math 3, Fall 009 Exam : Solutios () a) ( poits) Determie for which positive real umbers p, is the followig improper itegral coverget, ad for which it is diverget. Evaluate the itegral for each value of

More information

THE SOLUTION OF NONLINEAR EQUATIONS f( x ) = 0.

THE SOLUTION OF NONLINEAR EQUATIONS f( x ) = 0. THE SOLUTION OF NONLINEAR EQUATIONS f( ) = 0. Noliear Equatio Solvers Bracketig. Graphical. Aalytical Ope Methods Bisectio False Positio (Regula-Falsi) Fied poit iteratio Newto Raphso Secat The root of

More information

1 Lecture 2: Sequence, Series and power series (8/14/2012)

1 Lecture 2: Sequence, Series and power series (8/14/2012) Summer Jump-Start Program for Aalysis, 202 Sog-Yig Li Lecture 2: Sequece, Series ad power series (8/4/202). More o sequeces Example.. Let {x } ad {y } be two bouded sequeces. Show lim sup (x + y ) lim

More information

) n. ALG 1.3 Deterministic Selection and Sorting: Problem P size n. Examples: 1st lecture's mult M(n) = 3 M ( È

) n. ALG 1.3 Deterministic Selection and Sorting: Problem P size n. Examples: 1st lecture's mult M(n) = 3 M ( È Algorithms Professor Joh Reif ALG 1.3 Determiistic Selectio ad Sortig: (a) Selectio Algorithms ad Lower Bouds (b) Sortig Algorithms ad Lower Bouds Problem P size fi divide ito subproblems size 1,..., k

More information

SCORE. Exam 2. MA 114 Exam 2 Fall 2016

SCORE. Exam 2. MA 114 Exam 2 Fall 2016 Exam 2 Name: Sectio ad/or TA: Do ot remove this aswer page you will retur the whole exam. You will be allowed two hours to complete this test. No books or otes may be used. You may use a graphig calculator

More information

Read carefully the instructions on the answer book and make sure that the particulars required are entered on each answer book.

Read carefully the instructions on the answer book and make sure that the particulars required are entered on each answer book. THE UNIVERSITY OF WARWICK FIRST YEAR EXAMINATION: Jauary 2009 Aalysis I Time Allowed:.5 hours Read carefully the istructios o the aswer book ad make sure that the particulars required are etered o each

More information

Merge and Quick Sort

Merge and Quick Sort Merge ad Quick Sort Merge Sort Merge Sort Tree Implemetatio Quick Sort Pivot Item Radomized Quick Sort Adapted from: Goodrich ad Tamassia, Data Structures ad Algorithms i Java, Joh Wiley & So (1998). Ruig

More information

Sums, products and sequences

Sums, products and sequences Sums, products ad sequeces How to write log sums, e.g., 1+2+ (-1)+ cocisely? i=1 Sum otatio ( sum from 1 to ): i 3 = 1 + 2 + + If =3, i=1 i = 1+2+3=6. The ame ii does ot matter. Could use aother letter

More information

The Binomial Theorem

The Binomial Theorem The Biomial Theorem Lecture 47 Sectio 9.7 Robb T. Koether Hampde-Sydey College Thu, Apr 8, 03 Robb T. Koether (Hampde-Sydey College The Biomial Theorem Thu, Apr 8, 03 / 7 Combiatios Pascal s Triagle 3

More information

MIDTERM 2 CALCULUS 2. Monday, October 22, 5:15 PM to 6:45 PM. Name PRACTICE EXAM

MIDTERM 2 CALCULUS 2. Monday, October 22, 5:15 PM to 6:45 PM. Name PRACTICE EXAM MIDTERM 2 CALCULUS 2 MATH 23 FALL 218 Moday, October 22, 5:15 PM to 6:45 PM. Name PRACTICE EXAM Please aswer all of the questios, ad show your work. You must explai your aswers to get credit. You will

More information

MTH 133 Solutions to Exam 2 November 16th, Without fully opening the exam, check that you have pages 1 through 12.

MTH 133 Solutions to Exam 2 November 16th, Without fully opening the exam, check that you have pages 1 through 12. Name: Sectio: Recitatio Istructor: INSTRUCTIONS Fill i your ame, etc. o this first page. Without fully opeig the exam, check that you have pages through. Show all your work o the stadard respose questios.

More information

1 Cabin. Professor: What is. Student: ln Cabin oh Log Cabin! Professor: No. Log Cabin + C = A Houseboat!

1 Cabin. Professor: What is. Student: ln Cabin oh Log Cabin! Professor: No. Log Cabin + C = A Houseboat! MATH 4 Sprig 0 Exam # Tuesday March st Sectios: Sectios 6.-6.6; 6.8; 7.-7.4 Name: Score: = 00 Istructios:. You will have a total of hour ad 50 miutes to complete this exam.. A No-Graphig Calculator may

More information

Sequence A sequence is a function whose domain of definition is the set of natural numbers.

Sequence A sequence is a function whose domain of definition is the set of natural numbers. Chapter Sequeces Course Title: Real Aalysis Course Code: MTH3 Course istructor: Dr Atiq ur Rehma Class: MSc-I Course URL: wwwmathcityorg/atiq/fa8-mth3 Sequeces form a importat compoet of Mathematical Aalysis

More information

MID-YEAR EXAMINATION 2018 H2 MATHEMATICS 9758/01. Paper 1 JUNE 2018

MID-YEAR EXAMINATION 2018 H2 MATHEMATICS 9758/01. Paper 1 JUNE 2018 MID-YEAR EXAMINATION 08 H MATHEMATICS 9758/0 Paper JUNE 08 Additioal Materials: Writig Paper, MF6 Duratio: hours DO NOT OPEN THIS BOOKLET UNTIL YOU ARE TOLD TO DO SO READ THESE INSTRUCTIONS FIRST Write

More information

Polynomial Multiplication and Fast Fourier Transform

Polynomial Multiplication and Fast Fourier Transform Polyomial Multiplicatio ad Fast Fourier Trasform Com S 477/577 Notes Ya-Bi Jia Sep 19, 2017 I this lecture we will describe the famous algorithm of fast Fourier trasform FFT, which has revolutioized digital

More information

Carleton College, Winter 2017 Math 121, Practice Final Prof. Jones. Note: the exam will have a section of true-false questions, like the one below.

Carleton College, Winter 2017 Math 121, Practice Final Prof. Jones. Note: the exam will have a section of true-false questions, like the one below. Carleto College, Witer 207 Math 2, Practice Fial Prof. Joes Note: the exam will have a sectio of true-false questios, like the oe below.. True or False. Briefly explai your aswer. A icorrectly justified

More information

n n 2 n n + 1 +

n n 2 n n + 1 + Istructor: Marius Ioescu 1. Let a =. (5pts) (a) Prove that for every ε > 0 there is N 1 such that a +1 a < ε if N. Solutio: Let ε > 0. The a +1 a < ε is equivalet with + 1 < ε. Simplifyig, this iequality

More information

Algorithms. Elementary Sorting. Dong Kyue Kim Hanyang University

Algorithms. Elementary Sorting. Dong Kyue Kim Hanyang University Algorithms Elemetary Sortig Dog Kyue Kim Hayag Uiversity dqkim@hayag.a.kr Cotets Sortig problem Elemetary sortig algorithms Isertio sort Merge sort Seletio sort Bubble sort Sortig problem Iput A sequee

More information

62. Power series Definition 16. (Power series) Given a sequence {c n }, the series. c n x n = c 0 + c 1 x + c 2 x 2 + c 3 x 3 +

62. Power series Definition 16. (Power series) Given a sequence {c n }, the series. c n x n = c 0 + c 1 x + c 2 x 2 + c 3 x 3 + 62. Power series Defiitio 16. (Power series) Give a sequece {c }, the series c x = c 0 + c 1 x + c 2 x 2 + c 3 x 3 + is called a power series i the variable x. The umbers c are called the coefficiets of

More information

Design and Analysis of Algorithms

Design and Analysis of Algorithms Desig ad Aalysis of Algorithms Probabilistic aalysis ad Radomized algorithms Referece: CLRS Chapter 5 Topics: Hirig problem Idicatio radom variables Radomized algorithms Huo Hogwei 1 The hirig problem

More information