Latest Activity In Study Groups

Join Your Study Groups

VU Past Papers, MCQs and More

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


Assignment No. 01
SEMESTER Spring 2021

CS502- Fundamentals of Algorithms

 

Total Marks: 20

 

Due Date: 19-05-2021

Instructions

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.

Objective

The objective of this assignment is

·     To give basic knowledge and understanding of Algorithms.

·     To be able to design simple algorithms.

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

Note:

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

Deadline

Your assignment must be uploaded/submitted on or before 19-05-2021.

 

 

 

 

Question No 01:                                                                                                                                (Marks:  10)

Suppose that one of the largest commercial bank branch in UAE has recently experienced a significant distress due to covid 19.  A huge No. of account holders withdraws the payment from the bank. Now manager want to check the total number of accounts those have less than 1000$.

 

You are required perform the following task:

A.     Write only Pseudocode to check the total number of accounts, who have less than 1000$ using array list.

B.     After writing Pseudocode calculate the worst-case time complexity T(n).

 

 

Question No 02:                                                                                                                                (Marks:  10)

A prime number is a number that can only be divided by itself and 1. Using the following code, we can check whether the number is prime or not. Your task is to find the time complexity of the following code with respect to worst case.

 

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;

            }

}

 

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

 

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

 

GOOD LUCK

 

Views: 852

Replies to This Discussion

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

CS502 Assignment 01 Spring 2021 Solution 

Click on the below link to download the file

CS502-Assignment-1-Solution-Spring-2021.pdf

One more idea solution CS502 File 

CS502-Assignment-1-Solution-Spring-2021-Idea-02.doc

CS502 Solution File one more 

CS502-Assignment-Solution-2021.docx

cs502assignment1solution2021 #cs502assignemnt1solutionspring2021
CS502 Assignment 1 Solution Spring 2021 | CS502 Assignment 1 Solution 2021

ye cost wali row kia hai ye smjh nhi aaya.

#cs502assignmentno1solution2021 #cs502assignment1solution2021 #advancescholars
CS502 Assignment no 1 Solution Spring 2021|CS502 Assignment 1 Solution 2021|Advance Scholars

CS502 Assignment 1 Solution Spring 2021 || Fundamentals of Algorithms|| 100% Correct Solution

CS502 Assignment 01 Spring 2021 Solution 

Click on the below link to download the file

CS502-Assignment-1-Solution-Spring-2021.pdf

CS502 Assignment No. 1 Spring 2021

 

Q.1) a

Pseudo Code

        arraylist ()

        for i=1 to no of accounts

                if amount < 1000$

                        arraylist (account_no)

        return false

 

Q.1) 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)

 

 

 

 

Q.2)

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)

 

One more idea solution CS502 File 

CS502-Assignment-1-Solution-Spring-2021-Idea-02.doc

RSS

Looking For Something? Search Below

VIP Member Badge & Others

How to Get This Badge at Your Profile DP

------------------------------------

Management: Admins ::: Moderators

Other Awards Badges List Moderators Group

© 2021   Created by + M.Tariq Malik.   Powered by

Promote Us  |  Report an Issue  |  Privacy Policy  |  Terms of Service