COMP285 Midterm Exam Department of Mathematics

Size: px
Start display at page:

Download "COMP285 Midterm Exam Department of Mathematics"

Transcription

1 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. Good Luck!!Mustafa Riza 1. Asymptotic Notatios: (a) Use the formal defiitios of O, Θ, ad Ω to determie weather the followig assertios are true or false. i. ( + 1)/ O( 3 ) ( + 1)/ ( 3 1 lim 3 = lim + ) 1 3 = lim Therefore the statemet is true. ii Θ() = 0 iii. lim = lim Therefore the statemet is true. 3 O() = lim = 0 = cost Therefore the statemet is true. (b) Cosider the followig Algorithm: Algorithm 1 Eigma(A[0.. 1, 0.. 1] lim 3 = lim /3 = 0 1: {Iput: A matrix A[0.. 1, 0.. 1] of real umbers} : for i 0 to do 3: for j i + 1 to 1 do 4: if A[i, j] A[j, i] the 5: retur false 6: ed if 7: ed for 8: ed for 9: retur true (a) What does this algorithm compute? ( P) This program checks if the matrix is symmetric or ot. 1

2 (b) What is its basic operatio? (3 P) The basic operatio is the compariso of the matrix elemets. (c) How may times is the basic operatio executed ad what is the efficiecy class of this altorithm? Depedig o if the matrix is symmetric or ot the umber of comparisos differ. I the best case the first compariso shows that the matrix is ot symmetric so i the best case we have Θ(1) efficiecy class. I the worst case we have to perform / comparisos, so i the worst case we have Θ( ) efficiecy class. I average we have to calculate the followig: 1 1 i = i=0 ( 1) = 1 Θ(). Recurrece Relatios: (10 P) (a) Solve the recurrece relatio: x() = x( 1) +, for > 0, x(0) = 0 x() = x( 1) + x() = x( ) + ( 1) + x() = x( 3) + ( 3) + ( 1) +. =. x() = x(0) x() = 1 ( + 1) (b) Solve the recurrece relatio: Substitute = k x() = x(/) +, for > 1, x(1) = 1 (Solve for = k ) x() = x( k ) + k x() = x( k ) + k 1 + k x() = x( k 3 ) + k + k 1 + k. =. x() = x(0) k + k 1 + k x() = k + k 1 + k k x() = i = k+1 1 i=0 back substitutio k = x() = 1

3 3. Brute Force Algorithms: (1 P) (a) For the the Selectio Sort Algorithm give below Algorithm SelectioSort(A[0.. 1] 1: {Sorts a give array by selectio sort} : {Iput: A usorted Array A[0.. 1] of elemets.} 3: {Output: A sorted Array A[0.. 1] i ascedig order.} 4: for i 0 to do 5: mi i 6: for j i + 1 to 1 do 7: if A[j] < A[mi] the 8: mi j 9: ed if 10: swap A[i] ad A[mi] 11: ed for 1: ed for (a) Please sort the list A, L, G, O, R, I, T, H, M i alphabetical order usig Selectio Sort Algorithm give below. A L G O R I T H M A G L O R I T H M A G H O R I T L M A G H I R O T L M A G H I L O T R M A G H I L M T R O A G H I L M O R T A G H I L M O R T (b) What is the basic operatio of the selectio sort algorithm? ( P) The basic operatio is compariso of elemets. (c) What is the efficiecy class of the selectio sort algorithm? The efficiecy class is Θ( ) 4. Divide ad Coquer: (35P) (a) Usig the Master Theorem, fid the order of growth of the followig recurreces: Recallig the Master Theorem: Theorem 1 If f() Θ( d ) with d 0 i the recurrece relatio T () = at (/b) + f(), the Θ( d ) if a < b d T () = Θ( d log ) if a = b d Θ( log b a ) if a > b d. i. T () = 4T (/) +, T (1) = 1. Accordig to the master theorem 1 we have a = 4, b =, d = 1, so we have the case of 4 > 1, i.e. T () = Θ( log 4 ) = Θ( ) 3

4 ii. T () = 4T (/) + 3, T (1) = 1. Accordig to the master theorem 1 we have a = 4, b =, d = 3, so we have the case of 4 < 3, i.e. T () = Θ( 3 ) (b) Apply the mergesort algorithm to sort the list A, L, G, O, R, I, T, H, M i alphabetical order. ALGORITHM ALGOR ITHM ALG OR IT HM AL G O R I T H M A L OR IT HM AL HIMT AGL AGLOR AGHILMORT (c) Give is the Quicksort Algorithm as followig: The partitio fuctio partitios the subarray usig a pivot key, where all elemets less tha the pivot key are put ito the array A[l..s 1] ad all elemets greater tha the pivot key are put ito the array A[s + 1..r]. The pivot key will be put as first elemet of the secod array, i.e. A[s]. i. State the recurrece relatio for umber of key comparisos for the best case ad solve this recurrece relatio to get the exact umber of key comparisos. (10 P) 4

5 Algorithm 3 Quicksort(A[l..r] 1: {Sorts a subarray by quicksort} : {Iput: A usorted subarray A[l..r] of A[0.. 1], defied by its left ad right idices l ad r} 3: {Output: Subarray A[l..r] i odecreasig order.} 4: if l < r the 5: s P artitio(a[l..r]) {s is the split positio} 6: Quicksort(A[l..s 1]) 7: Quicksort(A[s..r]) 8: ed if I the best case the Quicksort algorithm works like the Mergesort algorithm so its recursio relatio is give as: C() = C(/) + Usig the Master Theorem Theorem 1 we ca easily verify that C() Θ( log ). ii. Describe the worst case sceario ad state the umber of comparisos i the worst case sceario usig the Θ otatio. I the worst case the pivot key is either the smallest or the biggest elemet of the list, so that the other elemets are either all greater or all smaller. So the we ca ot really say that we have a partitio. I this case the Algorithm works like the selectio sort algorithm ad its efficiecy class is Θ( ). iii. Sort the list A, L, G, O, R, I, T, H, M usig the quicksort algorithm for the partitio fuctio usig the first elemet of the subarray as pivot key. A G I H L O R T M A G I H L M O R T 5. Biary Trees: (15 P) (a) Draw the biary search tree by isertig the elemets of the list L, O, G, A, R, I, T, H, M oe by oe to the biary search tree. (8 P) L G O A I M R H T (b) Perform pre-, i-, ad postorder traversal for the biary search tree i questio 5a. (7 P) pre-order: i-odert: post-order: L G A I H O M R T A H I G M T R O L 5

6 6. Decrease ad Coquer: Give is the followig Isertio Sort Algorithm: (15 P) Algorithm 4 IsertioSort(A[l..r]) 1: {Sorts a array by isertiosort} : {Iput: A usorted array A[0.. 1] of elemets.} 3: {Output: A array A[0.. 1] sorted i odecreasig order.} 4: for i 1 to 1 do 5: v A[i] 6: j i 1 7: while j 0 ad A[j] > v do 8: A[j + 1] A[j] 9: j j 1 10: ed while 11: A[j + 1] v 1: ed for (a) Use the isertio sort algorithm to sort the array A, L, G, O, R, I, T, H, M. A G L O R I T H M A G L O R I T H M A G L O R I T H M A G I L O R T H M A G I L O R T H M A G H I L O R T M Note: The bold face letters deote the sorted array. We start at the secod positio as oe elemet i a array is by defiitio already sorted. The we go oe by oe through the array by comparig startig from the biggest elemet to the smallest elemet i the sorted array. Oce we have foud the correct positio we isert the elemet ito the correct positio. (b) Describe the worst case sceario for the isertio sort algorithm ad state the umber of key comparisios usig the Θ otatio. I the worst case the array has to be sorted i reverse order so we have to carry out comparisos, i.e. Θ( ) comparisos. (c) Describe the best case sceario for the isertio sort algorithm ad state the umber of key comparisos usig the Θ otatio. I the best case the array is already sorted. Therefore for each step we have to perform exactly oe compariso, i.e. i total we have to perform Θ() comparisos for a array with elemets. 6

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

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

Matriculation number: You have 90 minutes to complete the exam of InformatikIIb. The following rules apply: Departmet of Iformatics Prof. Dr. Michael Böhle Bizmühlestrasse 14 8050 Zurich Phoe: +41 44 635 4333 Email: boehle@ifi.uzh.ch AlgoDat Midterm1 Sprig 016 08.04.016 Name: Matriculatio umber: Advice You have

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Average-Case Analysis of QuickSort

Average-Case Analysis of QuickSort Average-Case Aalysis of QuickSort Comp 363 Fall Semester 003 October 3, 003 The purpose of this documet is to itroduce the idea of usig recurrece relatios to do average-case aalysis. The average-case ruig

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

Design and Analysis of ALGORITHM (Topic 2)

Design and Analysis of ALGORITHM (Topic 2) DR. Gatot F. Hertoo, MSc. Desig ad Aalysis of ALGORITHM (Topic 2) Algorithms + Data Structures = Programs Lessos Leared 1 Our Machie Model: Assumptios Geeric Radom Access Machie (RAM) Executes operatios

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

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

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

Divide and Conquer. 1 Overview. 2 Multiplying Bit Strings. COMPSCI 330: Design and Analysis of Algorithms 1/19/2016 and 1/21/2016

Divide and Conquer. 1 Overview. 2 Multiplying Bit Strings. COMPSCI 330: Design and Analysis of Algorithms 1/19/2016 and 1/21/2016 COMPSCI 330: Desig ad Aalysis of Algorithms 1/19/2016 ad 1/21/2016 Lecturer: Debmalya Paigrahi Divide ad Coquer Scribe: Tiaqi Sog 1 Overview I this lecture, a importat algorithm desig techique called divide-ad-coquer

More information

A Probabilistic Analysis of Quicksort

A Probabilistic Analysis of Quicksort A Probabilistic Aalysis of Quicsort You are assumed to be familiar with Quicsort. I each iteratio this sortig algorithm chooses a pivot ad the, by performig comparisios with the pivot, splits the remaider

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

COMP26120: Introducing Complexity Analysis (2018/19) Lucas Cordeiro

COMP26120: Introducing Complexity Analysis (2018/19) Lucas Cordeiro COMP60: Itroduig Complexity Aalysis (08/9) Luas Cordeiro luas.ordeiro@mahester.a.uk Itroduig Complexity Aalysis Textbook: Algorithm Desig ad Appliatios, Goodrih, Mihael T. ad Roberto Tamassia (hapter )

More information

Algorithm Analysis. Algorithms that are equally correct can vary in their utilization of computational resources

Algorithm Analysis. Algorithms that are equally correct can vary in their utilization of computational resources Algorithm Aalysis Algorithms that are equally correct ca vary i their utilizatio of computatioal resources time ad memory a slow program it is likely ot to be used a program that demads too much memory

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

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

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

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

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

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

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

Divide and Conquer. 1 Overview. 2 Insertion Sort. COMPSCI 330: Design and Analysis of Algorithms 1/19/2016 and 1/21/2016

Divide and Conquer. 1 Overview. 2 Insertion Sort. COMPSCI 330: Design and Analysis of Algorithms 1/19/2016 and 1/21/2016 COMPSCI 330: Desig ad Aalysis of Algorithms 1/19/2016 ad 1/21/2016 Divide ad Coquer Lecturer: Debmalya Paigrahi Scribe: Tiaqi Sog, Tiayu Wag 1 Overview This set of otes is orgaized as follows. We begi

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

2. ALGORITHM ANALYSIS

2. ALGORITHM ANALYSIS 2. ALGORITHM ANALYSIS computatioal tractability survey of commo ruig times 2. ALGORITHM ANALYSIS computatioal tractability survey of commo ruig times Lecture slides by Kevi Waye Copyright 2005 Pearso-Addiso

More information

Enumerative & Asymptotic Combinatorics

Enumerative & Asymptotic Combinatorics C50 Eumerative & Asymptotic Combiatorics Notes 4 Sprig 2003 Much of the eumerative combiatorics of sets ad fuctios ca be geeralised i a maer which, at first sight, seems a bit umotivated I this chapter,

More information

Lecture Notes for CS 313H, Fall 2011

Lecture Notes for CS 313H, Fall 2011 Lecture Notes for CS 313H, Fall 011 August 5. We start by examiig triagular umbers: T () = 1 + + + ( = 0, 1,,...). Triagular umbers ca be also defied recursively: T (0) = 0, T ( + 1) = T () + + 1, or usig

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

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

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

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

Area As A Limit & Sigma Notation

Area As A Limit & Sigma Notation Area As A Limit & Sigma Notatio SUGGESTED REFERENCE MATERIAL: As you work through the problems listed below, you should referece Chapter 5.4 of the recommeded textbook (or the equivalet chapter i your

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

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

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

Chapter 5.4 Practice Problems

Chapter 5.4 Practice Problems EXPECTED SKILLS: Chapter 5.4 Practice Problems Uderstad ad kow how to evaluate the summatio (sigma) otatio. Be able to use the summatio operatio s basic properties ad formulas. (You do ot eed to memorize

More information

Let us give one more example of MLE. Example 3. The uniform distribution U[0, θ] on the interval [0, θ] has p.d.f.

Let us give one more example of MLE. Example 3. The uniform distribution U[0, θ] on the interval [0, θ] has p.d.f. Lecture 5 Let us give oe more example of MLE. Example 3. The uiform distributio U[0, ] o the iterval [0, ] has p.d.f. { 1 f(x =, 0 x, 0, otherwise The likelihood fuctio ϕ( = f(x i = 1 I(X 1,..., X [0,

More information

CS161 Design and Analysis of Algorithms. Administrative

CS161 Design and Analysis of Algorithms. Administrative CS161 Desig ad Aalysis of Algorithms Da Boeh 1 Admiistrative Lecture 1, April 3, 1 Web page http://theory.staford.edu/~dabo/cs161» Hadouts» Aoucemets» Late breakig ews Gradig ad course requiremets» Midterm/fial/hw»

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

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

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

) 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

Infinite Sequences and Series

Infinite Sequences and Series Chapter 6 Ifiite Sequeces ad Series 6.1 Ifiite Sequeces 6.1.1 Elemetary Cocepts Simply speakig, a sequece is a ordered list of umbers writte: {a 1, a 2, a 3,...a, a +1,...} where the elemets a i represet

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

MATH 2300 review problems for Exam 2

MATH 2300 review problems for Exam 2 MATH 2300 review problems for Exam 2. A metal plate of costat desity ρ (i gm/cm 2 ) has a shape bouded by the curve y = x, the x-axis, ad the lie x =. Fid the mass of the plate. Iclude uits. Fid the ceter

More information

MATH 2300 review problems for Exam 2

MATH 2300 review problems for Exam 2 MATH 2300 review problems for Exam 2. A metal plate of costat desity ρ (i gm/cm 2 ) has a shape bouded by the curve y = x, the x-axis, ad the lie x =. Fid the mass of the plate. Iclude uits. (b) Fid the

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

Singular Continuous Measures by Michael Pejic 5/14/10

Singular Continuous Measures by Michael Pejic 5/14/10 Sigular Cotiuous Measures by Michael Peic 5/4/0 Prelimiaries Give a set X, a σ-algebra o X is a collectio of subsets of X that cotais X ad ad is closed uder complemetatio ad coutable uios hece, coutable

More information

Linear chord diagrams with long chords

Linear chord diagrams with long chords Liear chord diagrams with log chords Everett Sulliva Departmet of Mathematics Dartmouth College Haover New Hampshire, U.S.A. everett..sulliva@dartmouth.edu Submitted: Feb 7, 2017; Accepted: Oct 7, 2017;

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

1 Counting and Stirling Numbers

1 Counting and Stirling Numbers 1 Coutig ad Stirlig Numbers Natural Numbers: We let N {0, 1, 2,...} deote the set of atural umbers. []: For N we let [] {1, 2,..., }. Sym: For a set X we let Sym(X) deote the set of bijectios from X to

More information

Unit 6: Sequences and Series

Unit 6: Sequences and Series AMHS Hoors Algebra 2 - Uit 6 Uit 6: Sequeces ad Series 26 Sequeces Defiitio: A sequece is a ordered list of umbers ad is formally defied as a fuctio whose domai is the set of positive itegers. It is commo

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

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

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

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

Economics 250 Assignment 1 Suggested Answers. 1. We have the following data set on the lengths (in minutes) of a sample of long-distance phone calls

Economics 250 Assignment 1 Suggested Answers. 1. We have the following data set on the lengths (in minutes) of a sample of long-distance phone calls Ecoomics 250 Assigmet 1 Suggested Aswers 1. We have the followig data set o the legths (i miutes) of a sample of log-distace phoe calls 1 20 10 20 13 23 3 7 18 7 4 5 15 7 29 10 18 10 10 23 4 12 8 6 (1)

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

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

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

It is always the case that unions, intersections, complements, and set differences are preserved by the inverse image of a function.

It is always the case that unions, intersections, complements, and set differences are preserved by the inverse image of a function. MATH 532 Measurable Fuctios Dr. Neal, WKU Throughout, let ( X, F, µ) be a measure space ad let (!, F, P ) deote the special case of a probability space. We shall ow begi to study real-valued fuctios defied

More information

CS161 Handout 05 Summer 2013 July 10, 2013 Mathematical Terms and Identities

CS161 Handout 05 Summer 2013 July 10, 2013 Mathematical Terms and Identities CS161 Hadout 05 Summer 2013 July 10, 2013 Mathematical Terms ad Idetities Thaks to Ady Nguye ad Julie Tibshirai for their advice o this hadout. This hadout covers mathematical otatio ad idetities that

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

SOLUTIONS TO EXAM 3. Solution: Note that this defines two convergent geometric series with respective radii r 1 = 2/5 < 1 and r 2 = 1/5 < 1.

SOLUTIONS TO EXAM 3. Solution: Note that this defines two convergent geometric series with respective radii r 1 = 2/5 < 1 and r 2 = 1/5 < 1. SOLUTIONS TO EXAM 3 Problem Fid the sum of the followig series 2 + ( ) 5 5 2 5 3 25 2 2 This series diverges Solutio: Note that this defies two coverget geometric series with respective radii r 2/5 < ad

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

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

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

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

CS4115 Database. 20. What is the time-complexity of squaring a matrix of size n n in Big-Oh notation?

CS4115 Database. 20. What is the time-complexity of squaring a matrix of size n n in Big-Oh notation? Sectio 1. Autum 00 Mid-Term 1. I a multiple choice exam, if egative markig is beig used, what should be the pealty for wrog aswers so that somebody who guesses throughout eds up with 0; each questio has

More information

The log-behavior of n p(n) and n p(n)/n

The log-behavior of n p(n) and n p(n)/n Ramauja J. 44 017, 81-99 The log-behavior of p ad p/ William Y.C. Che 1 ad Ke Y. Zheg 1 Ceter for Applied Mathematics Tiaji Uiversity Tiaji 0007, P. R. Chia Ceter for Combiatorics, LPMC Nakai Uivercity

More information

DATA STRUCTURES I, II, III, AND IV

DATA STRUCTURES I, II, III, AND IV Data structures DATA STRUCTURES I, II, III, AND IV I. Amortized Aalysis II. Biary ad Biomial Heaps III. Fiboacci Heaps IV. Uio Fid Static problems. Give a iput, produce a output. Ex. Sortig, FFT, edit

More information

6 Integers Modulo n. integer k can be written as k = qn + r, with q,r, 0 r b. So any integer.

6 Integers Modulo n. integer k can be written as k = qn + r, with q,r, 0 r b. So any integer. 6 Itegers Modulo I Example 2.3(e), we have defied the cogruece of two itegers a,b with respect to a modulus. Let us recall that a b (mod ) meas a b. We have proved that cogruece is a equivalece relatio

More information

CSE 332. Data Structures and Parallelism

CSE 332. Data Structures and Parallelism Aam Blak Lecture 6a Witer 2017 CSE 332 Data Structures a Parallelism CSE 332: Data Structures a Parallelism More Recurreces T () T (/2) T (/2) T (/4) T (/4) T (/4) T (/4) P1 De-Brief 1 You i somethig substatial!

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

n m CHAPTER 3 RATIONAL EXPONENTS AND RADICAL FUNCTIONS 3-1 Evaluate n th Roots and Use Rational Exponents Real nth Roots of a n th Root of a

n m CHAPTER 3 RATIONAL EXPONENTS AND RADICAL FUNCTIONS 3-1 Evaluate n th Roots and Use Rational Exponents Real nth Roots of a n th Root of a CHAPTER RATIONAL EXPONENTS AND RADICAL FUNCTIONS Big IDEAS: 1) Usig ratioal expoets ) Performig fuctio operatios ad fidig iverse fuctios ) Graphig radical fuctios ad solvig radical equatios Sectio: Essetial

More information

Ma 530 Introduction to Power Series

Ma 530 Introduction to Power Series Ma 530 Itroductio to Power Series Please ote that there is material o power series at Visual Calculus. Some of this material was used as part of the presetatio of the topics that follow. What is a Power

More information

The picture in figure 1.1 helps us to see that the area represents the distance traveled. Figure 1: Area represents distance travelled

The picture in figure 1.1 helps us to see that the area represents the distance traveled. Figure 1: Area represents distance travelled 1 Lecture : Area Area ad distace traveled Approximatig area by rectagles Summatio The area uder a parabola 1.1 Area ad distace Suppose we have the followig iformatio about the velocity of a particle, how

More information

Chapter 6. Advanced Counting Techniques

Chapter 6. Advanced Counting Techniques Chapter 6 Advaced Coutig Techiques 6.: Recurrece Relatios Defiitio: A recurrece relatio for the sequece {a } is a equatio expressig a i terms of oe or more of the previous terms of the sequece: a,a2,a3,,a

More information

On a Smarandache problem concerning the prime gaps

On a Smarandache problem concerning the prime gaps O a Smaradache problem cocerig the prime gaps Felice Russo Via A. Ifate 7 6705 Avezzao (Aq) Italy felice.russo@katamail.com Abstract I this paper, a problem posed i [] by Smaradache cocerig the prime gaps

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

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

Homework 9. (n + 1)! = 1 1

Homework 9. (n + 1)! = 1 1 . Chapter : Questio 8 If N, the Homewor 9 Proof. We will prove this by usig iductio o. 2! + 2 3! + 3 4! + + +! +!. Base step: Whe the left had side is. Whe the right had side is 2! 2 +! 2 which proves

More information

The multiplicative structure of finite field and a construction of LRC

The multiplicative structure of finite field and a construction of LRC IERG6120 Codig for Distributed Storage Systems Lecture 8-06/10/2016 The multiplicative structure of fiite field ad a costructio of LRC Lecturer: Keeth Shum Scribe: Zhouyi Hu Notatios: We use the otatio

More information