© All Rights Reserved

9 views

© All Rights Reserved

- c++_arrays_chapter_9_class_xii
- New Syllabus
- Data Structure
- Brother DCP8065DN MFC8870DW Service Manual
- Full Project on BubbleSort Algorithm
- Lecture 2
- Warora Piping
- Advanced Data Structures Syllabus
- Heaps
- 1 - Intro to Algorithms
- Ge8161 Python Programming Lab Record
- Konica Minolta QMS 4060 Service Manual.pdf
- new FINAL 1
- Epson stylus cx3900.pdf
- Fs c5350dnensmr1
- Sync Sort
- 9A5301 Mathematical Foundations of Computer Science
- More Bi Go
- 1.Introduction ToDS Algorithms Day1
- Books

You are on page 1of 6

there are an equal number of subsets that contain n and that dont. We

obtain the recurrence relation

a1 = 1, an = 2an1 (n 2).

Solution: an = 2n .

2. Let an be the regions of the plane formed by n mutually intersecting

circles. Then a1 = 2, and for n 2, the last circle added divides 2(n 1)

previously existing regions into 2 each, yielding an = an1 + 2(n 1). We

obtain the recurrence relation

a1 = 2, an = an1 + 2(n 1) (n 2).

Solution:

an = 2 + 2 + 4 + 6 + + 2(n 1) = 2 + (n 1)n = n2 n + 2.

3. Assume you have 4 types of 1-cent stamps and 5 types of 2-cent stamps.

Let an be the number of ways to paste these stamps in a row on an envelope

to create a postage of n cents. Then a1 = 4, a2 = 21, and for n 3,

an = 4an1 + 5an2 . Reason: There are 4 ways to start with a penny stamp,

followed by an1 ways to add n 1 more cents, and there are 5 ways to start

with a 2-cent stamp, followed by an2 ways to add n 2 more stamp. We

obtain the recurrence relation

a1 = 4, a2 = 21, an = 4an1 + 5an2 (n 3).

Solution: Write Dan = an1 . Then

(1 4D 5D2 )an = 0,

(1 5D)(1 + D)an = 0.

The most general solution to (1rD)an = 0 is an = prn . Hence two solutions

are an = p5n and an = q(1)n , and an = p5n + q(1)n is another solution.

Choosing p and q so that a1 = 4 and a2 = 21 yields p = 56 and q = 16 . Hence

5

1

an = 5n + (1)n .

6

6

1

numbers into ascending order: If there is only one number, do nothing. Otherwise, separate the list into two sublists of length 2n1 , sort the first sublist

using an1 comparisons, sort the second sublist using an1 comparisons, then

merge the two lists together using 2n comparisons. Computer scientists refer

to this as the Merge-Sort Algorithm and our analysis yields the recurrence

relation

a0 = 0, an = 2an1 + 2n (n 1).

This implies

(1 2D)an = 2n ,

(1 2D)2 an = 0.

Therefore a homogeneous recurrence relation satisfied by an is

an 4an1 + 4an2 = 0 (n 2).

an = rn , an = nrn , an = n2 rn , ..., an = nk1 rn .

solution to (1 rD)an . This is true.

Now assume that solutions to (1rD)k an are an = rn , nrn , n2 rn , . . . , nk1 an .

Then these are all solutions to (1 rD)k+1 an = 0 because

(1 rD)k+1 an = (1 rD)(1 rD)k an = (1 rD)0 = 0.

Now consider an = nk rn . Then

(1 rD)k+1 an = (1 rD)k (1 rD)an = (1 rD)k (an ran1 ).

Lets calculate an ran1 . We have

an ran1 = nk rn r(n 1)k rn1 = (nk (n 1)k )rn .

2

k

X

k j

(n 1) =

n (1)kj ,

j

j=0

k

therefore

k1

X

k j

n (n 1) =

n (1)kj+1 .

j

j=0

k

nk (n 1)k = c0 + c1 n + c2 n2 + + ck1 nk1 .

Therefore

an ran1 = c0 rn + c1 nrn + c2 n2 rn + + ck1 nk1 rn ,

(1 rD)k+1 an = (1 rD)k (c0 rn + c1 nrn + c2 n2 rn + + ck1 nk1 rn ) = 0.

Hence the Lemma is true by the Principle of Mathematical Induction.

6. We return to Problem 4. It satisfies the recurrence relation

a0 = 0, a1 = 2, (1 2D)2 an = 0 (n 2).

Two solutions to (1 2D)2 an = 0 are an = 2n and an = n2n , and we can

combine them to form the solution an = p2n + qn2n . We need only choose p

and q so that a0 = 0 and a1 = 2. Doing this yields p = 0, q = 1, an = n2n .

7. The number of comparisons required to sort a list of n numbers using

Merge-Sort is 2n log2 (2n). Reason: Let k be an integer such that

2k1 n < 2k .

We will pad our list to length 2k by adding 2k n zeros to the end of it. We can

sort this list using k2k comparisons. Given that 2k 2n and k < log2 (2n),

we have k2k (log2 (2n))(2n) = 2n log2 (2n).

8. Another sorting algorithm is Bubble Sort. To sort a 1-element list (A1 ),

do nothing. To sort a 2-element list (A1 , A2 ), set A1 aside, sort the list (A2 ),

then place A1 in the correct position relative to A1 . To sort a 3-element

list (A1 , A2 , A3 ), set A1 aside, sort the list (A2 , A3 ) into (A02 , A03 ), then place

3

A1 in the correct position relative to (A02 , A03 ). In general, to sort the list

(A1 , A2 , . . . , An ), set A1 aside, sort the list (A2 , . . . , An ) into the sorted list

(A02 , . . . , A0n ), then place A1 in the correct position relative to A02 , . . . , A0n .

The algorithm for placing A1 in the correct position is to slide it past all

numbers that are smaller than it (the bubbling operation). This requires at

most n1 comparisons. Hence if an is the worst-case number of comparisons

required to sort an n-element list, then a1 = 0 and an = an1 + (n 1). The

solution to this recurrence relation is an = 0 + 1 + + (n 1) = 12 n2 12 n.

9. Consider the recurrence relation

a0 = 5, a1 = 6, an = an1 + 6an2 + 2n + 5 3n + n (n 2).

We reorganize this to

an an1 6an2 = 2n + 5 3n + n1n ,

(1 + 2D)(1 3D)an = 2n + 5 3n + n1n .

By the Lemma in Item 5 above, (1 2D)2n = 0, (1 3D)(5 3n ) = 0, and

(1 D)2 (n1n ) = 0. Applying the recurrence relation above by

(1 2D)(1 3D)(1 D)2

we obtain

(1 2D)(1 + 2D)(1 3D)2 (1 D)2 an = 0 (n 6).

To solve this recurrence relation we need need to provide 6 initial conditions,

a0 through a5 . These can be produced using the original recurrence relation.

By the Lemma in Item 5 again, solutions to the recurrence relation include

2n , (2)n , 3n , n3n , 1n , and n1n . A solution involving 6 constants is

an = c1 2n + c2 (2)n + c3 3n + c4 n3n + c5 1n + c6 n1n .

Using the initial conditions

(a0 , a1 , a2 , a3 , a4 , a5 ) = (5, 6, 87, 269, 1216, 4082)

we obtain a system of 6 equations in 6 unknowns whose solution is

(c1 , c2 , c3 , c4 ,5 , c6 ) = (1,

4

13 1

176 49

, , 3, , ).

45 20

36 6

Therefore

an = 2n +

13

176

49

1

(2)n + 3n + 3n3n 1n n1n .

45

20

36

6

relation

an = 1, an = an1 + (2n 1)2 (n 2).

We can reorganize this to

an = 1, (1 D)an = 4n2 4n + 1.

Applying (1 D)3 to both sides yields

(1 D)4 an = 0.

Solutions to this equation include 1, n, n2 , n3 . Setting

an = c0 + c1 n + c2 n2 + c3 n3

and using the 4 initial conditions

(a1 , a2 , a3 , a4 ) = (1, 10, 35, 84)

we obtain

4

1

(c0 , c1 , c2 , c3 ) = (0, , 0, ).

3

3

This yields

12 + 32 + + (2n 1)2 =

4n3 n

n(2n 1)(2n + 1)

=

.

3

3

relation is

an = an1 + an2 (n 2),

(1 D D2 )an = 0.

r + s = 1 and rs = 1.

1 5

Solving the system of equations yields r = 2 and s = 1+2 5 . Setting

!n

!n

1 5

1 + 5

an = p

+q

2

2

and solving for p and q yields

an =

1

2

!n+1

5

1 +

2

!n+1

5

- c++_arrays_chapter_9_class_xiiUploaded bypranjal
- New SyllabusUploaded byAditya Sawant
- Data StructureUploaded byKamal Cheema
- Brother DCP8065DN MFC8870DW Service ManualUploaded byLuiz C. Pinho
- Full Project on BubbleSort AlgorithmUploaded bySaugat Timilsina
- Lecture 2Uploaded byBilal Awan
- Warora PipingUploaded byAsan Ibrahim
- Advanced Data Structures SyllabusUploaded bypavani_raavi3077
- HeapsUploaded bybdb3auty92
- 1 - Intro to AlgorithmsUploaded byM8R-ya0sm5
- Ge8161 Python Programming Lab RecordUploaded bythanammal indu
- Konica Minolta QMS 4060 Service Manual.pdfUploaded bySerge Macia
- new FINAL 1Uploaded byV.v. Vinoth
- Epson stylus cx3900.pdfUploaded byFernando Palma Galindo
- Fs c5350dnensmr1Uploaded byventas1 equitech
- Sync SortUploaded byApurva Kapoor
- 9A5301 Mathematical Foundations of Computer ScienceUploaded bysivabharathamurthy
- More Bi GoUploaded byIces Matara
- 1.Introduction ToDS Algorithms Day1Uploaded byRiham Abdallah
- BooksUploaded byMorgen Sudyanto
- 2012-13_04_ISUploaded bygocebuseski
- 11 SortingUploaded bysalmanshokha
- Book12Uploaded byAfrizal Fonna
- 13 STL AlgorithmsUploaded byyashbanwani2014
- ar-miningUploaded bysuchi87
- 5000.pdfUploaded byOSCAR
- Questionnaires (1)Uploaded bygeorgewheeler8
- XtraTreeListAboutUploaded bya7451t
- US Federal Reserve: datatabUploaded byThe Fed
- SSGxerx_01Uploaded bytrugenu

- Baclochistan Board of Intermediate and Secondary Education Past Papers 10th Science 5yearsUploaded byasan books
- JLA_Synthetic_Planning.pdfUploaded byNatalia Larionova
- Medical Study GuideUploaded bycontentseeker3401
- Atiyah Macdonald chapter 4 solutionsUploaded byZach49899
- Cerny_IUploaded byJefriYoseph
- Uncertainty Analysis Principles and MethodsUploaded byOilGasRosettaStone
- ApSIC.Xbench.2.9.UserGuide.EN.pdfUploaded byTerra Guzman
- Encyclopedia+of+Medical+Decision+MakingUploaded byAgam Reddy M
- What is the Nebular TheoryUploaded byanika fierro
- V Pp RadiasiUploaded byAdintaka Galihsinara
- Medical English ExerciseUploaded byQuang Nguyen
- CBR TEST PracticalUploaded byRehan Ali
- Windsor -Chariot IScrub 24-26cUploaded byNestor Marquez-Diaz
- Sea300Uploaded byPetrica
- 3- Response of Overground Pipelines to Random Ground MotionUploaded byOmer Tokh
- MSCI Quality Indices MethodologyUploaded byTian-Yu Tan
- Kitik CalvinUploaded byLaurentius Calvin
- WHXB20090709[1] Limonene Corr InhibitorUploaded byfisco4ril
- Pre Lab RectificationUploaded byMohamed-DeqSabriye
- StepperUploaded byahmad_syafrudin_1
- A Dictionary of Units ~ Part 1Uploaded bykapil
- Slide Assignment Example 2_ Fiber-Wireless (FiWi) Access NetworksUploaded bycaj7687
- DesignBuilder-Simulation-Training-SlidesUploaded byviv_1001
- RefsUploaded byrezwan17
- m13s2561616a elitesemiconductormemorytechnologyUploaded byapi-432313169
- How_to_Grok_GREPUploaded byRick Gordon
- fdfsaUploaded byArith Ctdl
- Ch0_230802Uploaded bymelanieverron
- 1355476Uploaded byfanixel
- MathsUploaded byYash Mangal