CS502 Fundamentals of Algorithms Assignment No. 1 Discussion & Solution Spring 2019 Due Date: May 15, 2019

Assignment No. 01
SEMESTER Spring 2019

CS502- Fundamentals of Algorithms


Total Marks: 20


Due Date: 15/05/2019


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 instructions

Your submission must include:


·         Assignment should be in .doc or .docx format.

·         Save your assignment with your ID (e.g. bx180200786.doc).

Assignment submission through email is NOT acceptable


The objective of this assignment is

·         To give basic knowledge and understanding of Algorithms.

·         To be able to understand and calculate the complexity of algorithms.

·         To be able to understand the growth rate of algorithms.




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 - 06


Your assignment must be uploaded/submitted at or before 15/05/2019.





Question No  01:   (Marks:  10)


The following algorithm (procedure) is computing the multiplication of two squared matrices. A[][] and B[][] are two squared matrices, Mul[][] is a square matrix which store the multiplication of A[][] and B[][]. As the matrices are squared so, “n” would be the number of columns or rows. You are required to calculate the worst case time complexity {T(n)} of this algorithm.


1    Matrix_Multiplication (A[][], B[][],Mul[][], int n)


2    Sum  = 0

3    for (int i to n)

4         for (int j to n)

5                     for (int k to n)

6                        Sum =  Sum + A[i][k] * B[k][j];


7         Mul[i][j] = Sum;



Note: Make sure that the alignment of each step/line is important in the algorithm, because it may indicate you that the loops are nested or in sequence.


Question No. 02   (Marks   10)


Consider the following function f(n) which represent the time complexity of an algorithm.


f(n)  = 2n2 + 4n + 7


As per the definition of Big O, we have, 0 ≤  f(n)  ≤ cg(n) , where c >0 and n ≥  n0


If  g(n) = n2 , find the value of c for which the upper bound cg(n)  holds.





For any query about the assignment, contact at CS502@vu.edu.pk







Tags: &, 1, 13, 2019, Algorithms, Assignment, CS502, Date:, Discussion, Due, More…Fundamentals, May, No., Solution, Spring, of

Views: 540




© 2019   Created by Irfan Khan MSCS.   Powered by

Badges  |  Report an Issue  |  Terms of Service