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 01 Fall 2021 Solution / Discussion Due Date: 10-12-2021

CS502 Assignment 01 Fall 2021 Solution / Discussion Due Date: 10-12-2021

Views: 777

### Replies to This Discussion

Share the Assignment Questions & Discuss Here....

Stay touched with this discussion, Solution idea will be uploaded as soon as possible in replies here before the due date.

Question No 01:                                                                                                                                (Marks:  5+5)

Part a)

Suppose one of the reputed higher educational institute working on an IT based project which is related to the student management system. This project has been divided into a number of modules and different teams are working on it. One team is facing an issue in the attendance module; they cannot find the total number of students absent in a class. Total class strength is 100.

• You must assist the team to write an efficient algorithm to find how many students are absent in a class.

Part b)

Find the Best-case and Worst-case time of the given piece of code.

Algorithm Test (n)

{

if (n <5 )

{

printf(“%d”, n);

}

else

{

for(i=0; i<n; i++)

{

printf(“%d”, i);

}

}

}

Question No 02:                                                                                                                                (Marks:  5+5)

Merge Sort follows divide and Conquer strategy therefore it’s a Recursive algorithm. Here is an unsorted list with eight elements.

 8 3 7 5 9 2 6 4

You are required to do the following tasks:

1. Sort the above list using Merge sort in ascending order.
2. Build Merge sort tree for both divide and combine phases.

#cs502assignment1solutionfall2021 #cs502assignmentsolution2022
CS502 Assignment 1 Solution Fall 2021 | CS502 Assignment 1 Solution 2022

CS502 Fall 2021 Solution file link

CS502-Assignment-1-Solution-Fall-2021-By-VU-Ning.pdf

#cs502assignment1solution2021 #cs502assignment1solutionfall2021 #cs502
cs502 Assignment 1 Solution 2021 || correct solution file fall 2021

Cs502 assignment Solution

CS502 One more idea solution file link

CS502_1_Sol_F21_VU_Ning.docx

# CS502 Assignment No 1 Solution fall 2021

Assignment No 1 fall 2021

CS502

Question No 01

SOLUTION:

Part A.

Pseudo Code:

arraylist ()

for i=1 to no of accounts

if amount < 1000\$

arraylist (account_no)

return false

Part B.

Time Complexity

 Cost Time C1 1 C2 n+1 C3 n C4 n/2 C5 1

Grand Total = c1+c2(n+1)+c3(n)+c4(n/2)+c5

= c1+c2n+c2+c3n+c4n/2+c5

= n(c2+c3+c4(1/2))+c1+c2+c5

= remove lowest order terms & constant

= O(n)

Question No 02

SOLUTION:

int arr[5], j, x , y, z;

for(x=0; x<5; x++)

{

cout"Enter the no."endl;

cin>>arr[x];

}

for(x=0;x<5;x++)

{

y=0;

for(j=2; j<arr[x];j++)

{

z=arr[x]%j;

if(z==0)

{

y=1;

break;

}

}

if(y==0)

coutarr[x]endl;

}

}

 Cost Time C1 1 C2 n+1 C3 n C4 n C5 n+1 C6 n C7 n(n+1)/2 C8 n2/2 C9 n2/2 C10 n C11 n C12 n C13 n/2

Grand Total = c1+c2n+c2+c3n+c4n+c5n+c5+c6n+c7n2/2+c7n/2+c8n2/2+c9n2/2+c10n+c11n+c12n+c13n/2

O(n2)

CS502 Solution file one more idea

CS502-Assignment-1-Solution-Fall-2021.docx

1

## Latest Activity

4 hours ago
monaliza and waseem are now friends
6 hours ago
Zubii joined + M.Tariq Malik's group

### MTH401 Differential Equations

yesterday
Zubii joined + M.Tariq Malik's group

### CS502 Fundamentals of Algorithms

yesterday
Zubii joined + M.Tariq Malik's group