CS502 Assignment 01 Fall 2021 Solution / Discussion Due Date: 10-12-2021
Tags:
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.
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:
#cs502assignment1solutionfall2021 #cs502assignmentsolution2022
CS502 Assignment 1 Solution Fall 2021 | CS502 Assignment 1 Solution 2022
CS502 Fall 2021 Solution file link
#cs502assignment1solution2021 #cs502assignment1solutionfall2021 #cs502
cs502 Assignment 1 Solution 2021 || correct solution file fall 2021
CS502 Solution file
Cs502 assignment Solution
CS502 One more idea solution file link
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 |
n^{2}/2 |
C9 |
n^{2}/2 |
C10 |
n |
C11 |
n |
C12 |
n |
C13 |
n/2 |
Grand Total = c1+c2n+c2+c3n+c4n+c5n+c5+c6n+c7n^{2}/2+c7n/2+c8n^{2}/2+c9n^{2}/2+c10n+c11n+c12n+c13n/2
O(n^{2})
CS502 Solution file one more idea
© 2022 Created by + M.Tariq Malik. Powered by
Promote Us | Report an Issue | Privacy Policy | Terms of Service
We are user-generated contents & non-commercial site since 2009. All product, videos, pictures & others contents on site don't seem to be beneath our Copyrights & belong to their respected owners & freely available on public domains. All Contents on site are for personal & non-commercial use.We believe in Our Policy & do according to them. If Any content is offensive in your Copyrights then please email at m.tariqmalik@gmail.com with copyright detail & We will happy to remove it immediately.
Management: Admins ::: Moderators
Awards Badges List | Moderators Group
All Members | Featured Members | Top Reputation Members | Angels Members | Intellectual Members | Criteria for Selection
Become a Team Member | Safety Guidelines for New | Site FAQ & Rules | Safety Matters | Online Safety | Rules For Blog Post