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

Looking For Something at vustudents.ning.com? Click Here to Search

www.bit.ly/vucodes

+ Link For Assignments, GDBs & Online Quizzes Solution

www.bit.ly/papersvu

+ Link For Past Papers, Solved MCQs, Short Notes & More


Dear Students! Share your Assignments / GDBs / Quizzes files as you receive in your LMS, So it can be discussed/solved timely. Add Discussion

How to Add New Discussion in Study Group ? Step By Step Guide Click Here.

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. 02
Semester: 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. 1.      Divide: Divides the problem into a small number of pieces
  2. 2.      Conquer: Solves each piece by applying divide and conquer to it recursively
  3. 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 Follow the New Added Discussions at Your Mail Address?

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


See Your Saved Posts Timeline

Views: 17818

.

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

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

+ Click Here to Search (Looking For something at vustudents.ning.com?)

+ Click Here To Join (Our facebook study Group)

Replies to This Discussion

ye solution theak hy ?

Very nice you have done

++msn .fb sy mera answr chori kar liya -_-  .. ye lo complete solution :P duaon mein yaad rakhna

Attachments:

yeh ist questtion ka ans hai kia

God Bless u Dear

ye sahi hy kia?

please koi ye to btyn na knsa solution kis question ka hy???????

plzzzzzzzzzz jaldi sy bta dyn knsa solution kis question ka hy???

or knsa solution theek hy???

part 1 ist ka ....
auer part 2 scnd ka .........scnd ka answr mjhe cnfrm nhe :)

 

KYA YE THEAK HEIN ??????PLEASE TELL ME

Assignment No. 02


ID=MC140401807

 

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.

Answer:

            Iteration method of power 2 k=log n

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

             = n + n log n

 

Question 2:

 

In Divide and conquer strategy, three main steps are performed:

 

  1. 1.      Divide: Divides the problem into a small number of pieces
  2. 2.      Conquer: Solves each piece by applying divide and conquer to it recursively
  3. 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.

Answer: 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 = 0
Solving this triangular system is straightforward:

a= 1/4 
b= 1/2 
c= 1/4 
d= 0

So,

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

YE theak hy ya galat ?

Part1
T(n)=T(n-1)+n*n as we know that T(n-1)=T(n-2)+n*n so we put this value
T(n)=T(n-2)+n*n+n*n =T(n-2)+2(n*n)
T(n)= T(n-2)+2(n*n) T(n-2)=T(n-3)+n*n so we put this value
T(n)= T(n-3)+2(n*n)+n*n= T(n-3)+3(n*n)
T(n-3)+3(n*n) T(n-3)=T(n-4)+n*n so we put this value
T(n)=T(n-4)+3(n*n)+n*n=T(n-4)+4(n*n)
..........
T(n)= T(n-k)+k(n*n)
If we set n=k
Then
T(n)= T(n-n)+n(n*n)=n^3

Part2:
SELECT(Array A,int p ,int r,int k=1)
if(p=r)
then return A[p]
else x CHOOSE_PIVOT(A,p,r)
q  PARTITION (A,p,r,x)
rankx  q-p+1
if k= rankx
then return x
if k< rankx
then return SELECT(A, p ,q-1, k)

RSS

Latest Activity

+¢αяєℓєѕѕ gιяℓ replied to +¢αяєℓєѕѕ gιяℓ's discussion My Quiz CS408 Last Date 21.11.2019 in the group CS408 Human Computer Interaction
4 minutes ago
Profile IconTayyaba Talib, ALI RAZA, Husnain Kan and 26 more joined Virtual University of Pakistan
6 minutes ago
+¢αяєℓєѕѕ gιяℓ replied to +¢αяєℓєѕѕ gιяℓ's discussion My Quiz CS408 Last Date 21.11.2019 in the group CS408 Human Computer Interaction
6 minutes ago
arooj liked + M.Tariq Malik's discussion EDU402 Final Term Papers Spring 2019 (24 August ~ 04 September 2019) & All Solved Past Papers, Solved MCQs & Helping Material
7 minutes ago
+¢αяєℓєѕѕ gιяℓ replied to +¢αяєℓєѕѕ gιяℓ's discussion My Quiz CS408 Last Date 21.11.2019 in the group CS408 Human Computer Interaction
7 minutes ago
+¢αяєℓєѕѕ gιяℓ added a discussion to the group CS408 Human Computer Interaction
9 minutes ago
+Mr President updated their profile
29 minutes ago
A_Q added a discussion to the group ENG513 Language Teaching Methods
48 minutes ago
ALEENA replied to + M.Tariq Malik's discussion Site Overview | Assignment Solutions | Past Papers Solutions | VU Students Features
49 minutes ago
+ !! "AS" !! replied to + !! "AS" !!'s discussion Ghalti...
51 minutes ago
ALEENA liked + Iuuoɔǝut +'s discussion MTH401_Mid term Solved (Part I) with refrence
56 minutes ago
Shine--Ex-VUStudent liked + !! "AS" !!'s discussion Yaha Har Cheez ..
57 minutes ago
Shine--Ex-VUStudent liked +¢αяєℓєѕѕ gιяℓ's discussion Iss tasvir ko Unwan Dein :-P
1 hour ago
ALEENA replied to ٥ دن's discussion Gunahon ki gehrai
1 hour ago
ALEENA replied to + !! "AS" !!'s discussion Ghalti...
1 hour ago
ALEENA replied to Siddiq khan kakar's discussion RIP
1 hour ago
Muhammad Hamza Mehmood liked Faiza's profile
1 hour ago
Profile IconKhan and zuha shah joined + M.Tariq Malik's group
1 hour ago
Khan joined + M.Tariq Malik's group
1 hour ago
Profile IconKhan and sardarni joined + M.Tariq Malik's group
1 hour ago

© 2019   Created by + M.Tariq Malik.   Powered by

Promote Us  |  Report an Issue  |  Privacy Policy  |  Terms of Service