# CS502 Assignment 1 Solution Fall 2021 - VU Answer

VU Answer Provide New CS502 Assignment 1 Solution Fall 2021. Easy to See Proper Complete CS502 Assignment 1 Solution 2021 and Download PDF File Below.

## CS502 ASSIGNMENT 1 SOLUTION FALL 2021

Due Date: 9 Dec 2021

Total Marks: 20

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

Question 1:

Part a)

Suppose one of the reputed higher educational institutes 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.

Solution:

Step 1: Start

Step 2: Initialize variables num=1, count=0, abs

Step 3: Start roll call

Step 4: Repeat the steps until num<=100

4.1 If student present

count=count+1

4.2 num=num+1

Step 5: abs=100-count

Step 6: Display “How many students are absent:” + abs

Step 7: Stop

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);

}

}

}

Solution:

Best case: O (1)

Worst Case: O (n)

Question 2:

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

Solution:

Proper Solution Diagram Given in Below CS502 PDF Solution File.

Check Also

All VU Assignment 1 Solution Fall 2021