Question No 1:
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 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)
cout<<arr[x]<<endl;
}
}
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$.
- Write only Pseudocode to check the total number of accounts, who have less than 1000$ using array list.
- After writing Pseudocode calculate the worst-case time complexity T(n).
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)
cout<<arr[x]<<endl;
}
}
Click Below To Download Solution File
Download
Recent Uploads:
Tags:
CS502 - Fundamentals of Algorithm Solution Assignment No 1 Spring 2021
cs502 assignment 1 solution 2021
vu assignments
vu assignments solutions 2021
vu services in Pakistan
vu solutions