L13_Adv_DandC

L13_Adv_DandC - 1-1Dealing with floors and ceilings...

Info iconThis preview shows pages 1–10. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 1-1Dealing with floors and ceilings individe-and-conquer recurrencesCOMP170Discrete Mathematical Toolsfor Computer Science2-1We have seen that whennis a power of2.T(n) =2T(n/2) +nifn≥2,1ifn= 1.isn(log2n+ 1). What happens whennis not a power of2?(*)2-2Note that, whennis not a power of2, a D&C recurrence willsplitnintobn/2canddn/2e. Eq(*)then becomesWe have seen that whennis a power of2.T(n) =2T(n/2) +nifn≥2,1ifn= 1.isn(log2n+ 1). What happens whennis not a power of2?(*)T(n) =T(bn/2c) +T(dn/2e) +nifn≥2,1ifn= 1.(**)2-3Note that, whennis not a power of2, a D&C recurrence willsplitnintobn/2canddn/2e. Eq(*)then becomesWe have seen that whennis a power of2.T(n) =2T(n/2) +nifn≥2,1ifn= 1.isn(log2n+ 1). What happens whennis not a power of2?(*)T(n) =T(bn/2c) +T(dn/2e) +nifn≥2,1ifn= 1.Whennis a power of2then(**)is defined by(*).(**)3-1Assume the following Theorem (to be proven later):Theorem 1Ifn1≤n2, thenT(n1)≤T(n2)3-2Assume the following Theorem (to be proven later):Theorem 1Ifn1≤n2, thenT(n1)≤T(n2)Letm= 2i+1be the smallest power of2≥n. Since the interval[n,2n-1]contains a power of2we havem <2n. So,T(n)≤T(m)=m(1 + log2m)≤2n(1 + log22n)=2n(2 + log2n)3-3Assume the following Theorem (to be proven later):Theorem 1Ifn1≤n2, thenT(n1)≤T(n2)Letm= 2i+1be the smallest power of2≥n. Since the interval[n,2n-1]contains a power of2we havem <2n. So,T(n)≤T(m)=m(1 + log2m)≤2n(1 + log22n)=2n(2 + log2n)This gives us anupper bound.4-1On the other hand,m/2 = 2i≤n < m. So,T(n)≥T(m2)=m2(1 + log2m2)>n2(1 + log2n2)=n2log2n4-2On the other hand,m/2 = 2i≤n < m. So,T(n)≥T(m2)=m2(1 + log2m2)>n2(1 + log2n2)=n2log2nThis gives us alower bound.5-1...
View Full Document

Page1 / 25

L13_Adv_DandC - 1-1Dealing with floors and ceilings...

This preview shows document pages 1 - 10. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online