VUsolutions Transferred to AchiKhasi.com
From December 2011, this blog www.VUsolutions.blogspot.com is transferred to http://achikhasi.com/vu/ . So, you may visit http://achikhasi.com/vu/ for latest study related help.
Back to home VUsolutions
VUsolutions Fans Club [join us for MORE solutions]
VUsolutions on Facebook
Important & Cool Links
Islamic Books in Urdu ! Beauty Tips in Urdu ! Online VU Lectures ! Unique Wallpapers ! Cooking Recipes - Urdu ! Women Kahani Ghar ! Health Tips in Urdu ! Showbiz Hidden Stories ! News Updates Online ! Bachon Ki Duniya ! Virtual University Study ! Prep to PhD Study Help ! Girls Women Block ! AIOU Study Block ! News & Politics Block ! Mix Plate Block - Others
Fundamentals of Algorithms
CS502-Fall2011
ASSIGNMENT1
Deadline
Your assignment must be uploaded/submitted at or before 1st November 2011.
Uploading instructions
Please view the assignment submission process document provided to you by the Virtual University to upload the assignment.
Guidelines
RULES FOR CALCULATING TIME COMPLEXITY AND BIG-OH Rule 00
Normally these formulas are very handy:
If x y = z then y z x = log
Also,
( )
2 1
1
n
n
i
i a a n a + = Σ=
( 1)
1 2
+ = Σ=
i n n
n
i
r
r r
m m
k
k
−
−
=
+
= Σ
1
1 1
0
( for n 1)
6
( 1)(2 1)
1
2 >=
+ +
= Σ=
i n n n
n
i
Rule 0
The condition that stops a loop executes ONE MORE time than the loop itself (the last time is when it is evaluated false)
Rule 1
for (i=0;i<n;i=i+k) Anything inside the loop will run approximately n/k times
Rule 2
for (i=n;i>0;i=i-k) Anything inside the loop will run approximately n/k times
Rule 3
for (i=1;i<n;i=i*k) Anything inside the loop will run approximately logkn times
Rule 4
for(i=1;i<=n;++i)
for (j=1;j<=i;++j)
The above nested loop approximately runs ½ n(n+1) times.
The variable j depends upon the value of i
Rule 5
for(i=1;i<=n;i=i*2)
for (j=1;j<=i;++j)
The statements in the above nested loop approximately run 2n-1 times.
The variable j depends upon the value of i
Rule 6
If the loop variables are independent then the total times a statement inside a nested loop is executed is equal to the product of the times the individual loopsrun e.g. for (i=0;i<n;++i)
for (j=0;j<m;++j)
A statement inside the above nested loop will run n*m times
Other Guidelines
While loop related information
Complexity of “while” loop depend upon the initial entrance condition if it remains true for “n” iterations it will be “n+1”; Note here “1” will be added for the last time check of the condition .Here this will be clear to you if the some logical conditions are checked other then counters then all complexity will be based on scenario of the problem and nature of the logical condition.
Function Growth rate concept
If some function f1(x)>f2(x) for positive values of x then the function f1(x) is said to have greater growth rate then f2(x). For example f1(x)=x5 and f2(x)= x6 it is obvious that f1(x) has greater growth rate ( 26 > 25).This concept relate to complexity of algorithm ,an algorithm having greater growth rate function means the algorithm has greater complexity here f2(x) is more complex then f1(x).
Estimated Time 2.5 hour
For all parts of the question to understand maximum time is 1.25 hours and for solution maximum time is 1.25 hour. It all depends upon your sheer concentration.
Question (4*5)
Write piece of pseudo codes having the following time complexities:
a) T1 (n) =n+
0
n
i
i
= Σ
b) T2 (n) =6n (log12n) +1+ (m/7) log (m)
c) O (z+m)
d) T3 (n) =
1
5 (1/)
n
i
n i
= Σ
Note: Where the base of “log “has not been mentioned take it as base “2”.
Back to home VUsolutions
Shaadi.com: Just create ur account & find ur partner or EARN money, its reall & EASY
VUsolutions Followers (Join NOW and Get Extra Benefits)
VU related Blogs
Install LATEST toolbar having lot of features - GET solutions on Desktop
toolbar powered by Conduit |