Dear Students,
Anyone have a solution for this new assignment. Kindly upload at VU Query forum.
Thanks!
Assignment No. 01 CS502- Fundamentals of Algorithms |
Total Marks: 20 Due Date: 26-11-2020 |
||||||||||
Instructions Please read the following instructions carefully before solving & submitting assignment: It should be clear that your assignment will not get any credit if: · The assignment is submitted after due date. · The submitted assignment does not open or file corrupt. · The assignment is full or partially copied from (other student or ditto copy from handouts or internet). · Student ID is not mentioned in the assignment File or name of file is other than student ID. · The assignment is not submitted in .doc or .docx format. Uploading instructionsYour submission must include:
ObjectiveThe objective of this assignment is · To give basic knowledge and understanding of Algorithms. · To be able to design simple algorithms. · To be able to understand and calculate the complexity of algorithms.
Note: Your answer must follow the below given specifications. · Font style: “Times New Roman” · Font color: “Black” · Font size: “12” · Bold for heading only. · Font in Italic is not allowed at all. · No formatting or bullets are allowed to use. · Your answer should be precise and to the point, avoid irrelevant detail.
Lectures Covered: This assignment covers Lecture # 01 - 08 Deadline Your assignment must be uploaded/submitted at or before 26/11/2020.
Question No 01: (Marks: 10) You are required to find the time complexity of the following codes with respect to worst case. Part A: for (i = 1 ; i<= n; i++) { for (i = 1 ; i<= n2 ; i++) { for (i = 1 ; i<= n3 ; i++) { a = x+y; } } } Part B:
for ( y = 1 ; y <= n; i++) { for (i = 1 ; i<= n2 ; i++) { for (i = 1 ; i<= n3 ; i++) { a = x+y; } } }
Question No 02: (Marks: 10) Write a simple algorithm (Only Pseudo code) about making 3x3 matrix table and also calculate the worst case time complexity T(n).
For any query about the assignment, contact at [email protected]
GOOD LUCK |
Solution:
Question No 01 Solution
Part A:
for (i = 1 ; i<= n; i++)……n times
{
for (i = 1 ; i<= n2 ; i++)…….n2 times
{
for (i = 1 ; i<= n3 ; i++)……n3 times
{
a = x+y;……. Constant c
}
}
}
T(n)=n*n2*n3+c
T(n)=n6+c
T(n)=n6
Part B:
for ( y = 1 ; y <= n; i++)……n times
{
for (i = 1 ; i<= n2 ; i++)…….n2 times
{
for (i = 1 ; i<= n3 ; i++)……n3 times
{
a = x+y;……. Constant c
}
}
}
T(n)=n*n2*n3+c
T(n)=n6+c
T(n)=n6
Question No 02 Solution
matrix (int rows, int columns)
array matrix [rows][columns]
for i 1 to rows…….n times{
do for j 1 to columns…….n times{
do print Matrix[rows][columns]<<tab;
}
print endline;
T(n)=n*n=n2
Students kindly share assignment files in relevant subject timely for discussion/solution.or directly share with us " Click here"
QueryVU WhatsApp groups subject wise Join Now