www.vustudents.ning.com

We non-commercial site working hard since 2009 to facilitate learning Read More. We can't keep up without your support. Donate.

# CS502 Assignment No 01 Fall 2020 Solution & Discussion Due Date: 26-11-2020

CS502 Assignment No 01 Fall 2020 Solution & Discussion Due Date: 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).

 1 2 3 4 5 6 7 8 9

=====================================Ended=======================================

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

GOOD LUCK

Views: 2178

### Replies to This Discussion

Our main purpose here discussion not just Solution

Students having same subject can start discussion here to solve assignment, GDB & Quiz and can clear their concepts until solution is provided.

P.S:    Please always try to add the discussion in proper format title like “CS101 Assignment / GDB No 01 Solution & Discussion Due Date: ___________”

Then copy Questions from assignment file and paste in Discussion.

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

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

**************

**********

CS502 One more idea solution file

CS502-Assignment-no. 1-Idea-Solution

CS502 Assignment No 01 Solution 100% Correct

/**************

CS502 Assignment#01 Solution Fall 2020

CS502_Assignment_No_01_Solution_Fall_2020

CS502 Assignment#01 Solution Fall 2020

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

CS502 Solution File

CS502-Sol-Assig#01-Fall-2020

# CS502 Assignment No 1 Solution Fall 2020 Idea Solution

*************

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+cT(n)=n6+cT(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+cT(n)=n6+cT(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`

1

2

3

4

## Latest Activity

8 hours ago

8 hours ago

### Mujy khamosh rehny dy 🌠︶︿︶🌠

9 hours ago
Masoom Shahzada, Ribqa and Muhammad Rizwan Ansari joined Virtual University of Pakistan
9 hours ago
19 hours ago
yesterday
Hamza( Graphic Designer) and Mehreen Tasneem are now friends
yesterday
Minahil khalid left a comment for ☞De Veloper☜♨
yesterday