We are here with you hands in hands to facilitate your learning & don't appreciate the idea of copying or replicating solutions. Read More>>

www.vustudents.ning.com

 www.bit.ly/vucodes + Link For Assignments, GDBs & Online Quizzes Solution www.bit.ly/papersvu + Link For Past Papers, Solved MCQs, Short Notes & More

# CS502 Assignment No. 02 Solution & Discussion Due Date: Dec 07, 2015

CS502 Assignment No. 02 Solution & Discussion Due Date: Dec 07, 2015

# CS502 - Fundamentals of Algorithms Assignment No. 02 Solution Fall 2015 Due Date Dec 07, 2015

 Assignment No. 02Semester: Fall 2015 CS502: Fundamentals of Algorithms Due Date:07/12/2015 Instructions Please read the following instructions carefully before submitting assignment:   It should be clear that your assignment will not get any credit (zero marks) if: The assignment is submitted after due date. The submitted assignment is other than .doc file. The submitted assignment does NOT open or file is corrupted. The assignment is copied (from other student or ditto copy from any other source).   Objective   The objective of this assignment is to enable students:   Write and solve recurrence relations of recursive algorithms using iteration method Design algorithm using Divide and conquer approach   Submission   You are required to submit your solution through LMS as MS Word document.   For any query about the assignment, contact at CS502@vu.edu.pk                                                              GOOD LUCK Question 1:   Consider the following recursive algorithm for computing the sum of the first n squares: Sum(n) = 12 + 22 + . . . + n2.   Algorithm: SUM(n) if n = 1 return 1 else return SUM(n − 1) + n ∗ n   Write recurrence relation for above algorithm and solve it using Iteration Method.   Question 2:   In Divide and conquer strategy, three main steps are performed:   1.      Divide: Divides the problem into a small number of pieces 2.      Conquer: Solves each piece by applying divide and conquer to it recursively 3.      Combine: Combines/merges the pieces together into a global solution.   Write an algorithm to find minimum number from a given array of size ‘n’ using divide and conquer approach. Lectures Covered:  This assignment covers first 15 Lectures. Deadline:             Your assignment must be uploaded/submitted at or before 07 Dec, 2015.

+ How to Join Subject Study Groups & Get Helping Material?

+ How to become Top Reputation, Angels, Intellectual, Featured Members & Moderators?

+ VU Students Reserves The Right to Delete Your Profile, If?

Views: 17810

.

+ http://bit.ly/vucodes (Link for Assignments, GDBs & Online Quizzes Solution)

+ http://bit.ly/papersvu (Link for Past Papers, Solved MCQs, Short Notes & More)

### Replies to This Discussion

Our main purpose here discussion not just Solution

We are here with you hands in hands to facilitate your learning and do not appreciate the idea of copying or replicating solutions.

First of all, if n == 1 you should probably return 1. And yes, this recursive function computes 1 + 2^3 + 3^3 + ... + n^3. How do we know that?

Well, take an example like n = 5;

• R(5) returns R(4) + 5^3
• R(4) returns R(3) + 4^3
• ....
• R(2) returns R(1) + 2^3
• R(1) returns 1

If you add them up => R(5) returns 5^3 + 4^3 + .. + 2^3 + 1.

can u plz explain it? i hve problem in algo

Denoting `S(n)` the sum of the first `n` cubes, `S(n)` must be a polynomial of the fourth degree in `n`, let

``S(n) = an^4+bn³+cn²+dn.``

This is because

1) `S(0)= 0`, so there is no independent term,

2) When computing `S(n)-S(n-1)`, which must equal `n³`, you get a polynomial of the third degree, by cancellation of the quartic term:

``S(n)-S(n-1) = a(n^4-(n-1)^4)+b(n³-(n-1)³)+c(n²-(n-1)²)+d(n-(n-1)).``

Developing and simplifying,

``a(4n³-6n²+4n-1)+b(3n²-3n+1)+c(2n-1)+d = n³. ``

Let us identify the coefficients:

``n³:  4a        =1 n²: -6a+3b     =0 n:   4a-3b+2c  =0 1:   -a +b -c+d=0Solving this triangular system is straigthforward:``
``a=1/4 b=1/2 c=1/4 d=0.``

and finally

``S(n) = (n^4+2n³+n²)/4 = n²(n+1)²/4.``
`` ``

first we should find the recurrence relation of sum of the first n squares
1^2 + 2^2 + . . . + n^2.

T(N)= T(n-2)+n^2
there is mistake in above recurrence relation. pls find it.
now it is easy to solve with iteration method.

is it comlete solution .?

Dear Students Don’t wait for solution post your problems here and discuss ... after discussion a perfect solution will come in a result. So, Start it now, replies here give your comments according to your knowledge and understandings....

I think asey hi ho ga

koi sloution ki form me upload kreen plz

Check iteration method of power 2 k=log n

T(n) = 2kT (n/(2k)) + (n+n+n+....+n)

= n + n log n

see on page 31

Lecture number 8 the solution s given

any one got the complet solution

## Latest Activity

25 minutes ago
Faizan 2nd BSCS and Junaid are now friends
2 hours ago
Faizan 2nd BSCS joined + M.Tariq Malik's group

### STA301 Statistics and Probability

2 hours ago
Faizan 2nd BSCS joined + M.Tariq Malik's group

### MTH601 Operations Research

2 hours ago
Faizan 2nd BSCS joined + M.Tariq Malik's group

### MTH501 Linear Algebra

2 hours ago
Faizan 2nd BSCS joined + M.Tariq Malik's group

### MGT201 Financial Management

2 hours ago
Faizan 2nd BSCS joined + M.Tariq Malik's group

### MTH603 Numerical Analysis

2 hours ago
+ M.Tariq Malik liked + !! ＳＡＲＡＨ's discussion hahhahahahaha!!!!!!
2 hours ago
+ ՏhehαrZααD + posted a discussion

### Indeed...

3 hours ago
+ ՏhehαrZααD + replied to BIA's discussion QURAN. 3:135
3 hours ago
+ ՏhehαrZααD + replied to BIA's discussion Quran 15:49
3 hours ago
+ ՏhehαrZααD + replied to BIA's discussion QURAN, 65:2-3
3 hours ago
+ ՏhehαrZααD + replied to BIA's discussion Quran 65:2-3
3 hours ago
+ !! ＳＡＲＡＨ posted a discussion

### hahhahahahaha!!!!!!

5 hours ago
8 hours ago
+ ! ! ! ! ᎠixieᎠuຮt꧂ liked ++"S.M.TALHA"++'s blog post کی جاناں میں کون
8 hours ago
Shine--Ex-VUStudent liked 21 October's discussion poetry
8 hours ago
Esha mirza updated their profile
8 hours ago
+ ՏhehαrZααD + liked 21 October's discussion poetry
9 hours ago
21 October posted discussions
9 hours ago

1

2

3