Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

JECRC University, Jaipur

School of Computer Applications


Assignment I August 2023
Class: MCA 1 (D)
Subject: Advance Data Structures and Algorithms
Subject Code – MCA 121B

Maximum Marks: 64
Date of Allotment: 01/09/2023
Date of Submission: 05/9/2023
Note: Late submissions will not be accepted and will be given zero marks.

Course Outcomes (COs):

1. To impart the basic concepts of data structures and algorithms.

2. To understand concepts about searching and sor ng techniques.

3. To understand basic concepts about stacks, queues, lists, trees and graphs.

4. To understanding about wri ng algorithms and step by step approach in solving problems with

the help of fundamental data structures.

5. To impart the basic concepts of algorithms implementa on in op mized me .

Instruc ons:

1. A empt all the ques ons.

2. Illustrate your answers with suitable examples and diagrams, wherever necessary.

3. Write relevant ques on numbers before wri ng the answer.

Section 1. (Answer the following questions) (5x2=10marks)

1. Explain Abstract data structures and logical data structures.

2. Explain the use of pointers and dynamic memory in DSA.

3. Write a program to take two integers as input and print all prime numbers between them.

4. Write a program to take 5 numbers as input and find LCM of those numbers.
5. Explain Big-O, Big-Omega, Big-Theta with examples and graphs and find Big-O, Big-Omega, Big-Theta for
f(n)=n*(log(n))^2 + 1000000*n + 7645.

Section 2. (3x7=21 marks)

1. Find the time complexity for the following c++ program .

void fun(int n)
{
int c=0;
while(n>=1)
{
n=n/12;
c++;
}
cout<<c;
}

int main()
{
int n;
for(int i=1;i<n;i=i*12)
{
fun(i);
}

int sum=0;
int j=0;
while(sum<=n)
{
j++;
sum=sum+j;
}

return 0;
}

2. Find the time complexity of the following code.

void fun(int n)
{
int c=0;
while(n>=1)
{
n=n/6;
c++;
}
cout<<c;
}

int main()
{
int n;
cin>>n;
for(int i=1;i<=n;i=i*3)
{
for(int j=1; j<=i*i;j++)
{
fun(i+j)
}
}
int k=0;
while(k<n)
{
k=k+2;
}
return 0;
}

3. Find the time complexity of the following code.

int fun(int n)
{
int c=0;
while(n>=1)
{
n=n/6;
c++;
}
return c;
}
int main()
{
int n;
cin>>n;
for(int i=1;i<=n;i++)
{
for(int j=1; j<=fun(i);j++)
{
for(int k=1;k<(n/2);k++)
{
cout<<"Elina"<<" ";
}
}
}

return 0;
}

Section 3. (Write a code for the following problems) (3x11=33marks)


1. Take an integer number input and keep adding its digits ad forming the new number until the number has
only 1 digit.
Example: 3542=14=5 ans=5; 927=18=9 ans=9. DO the problem in O(1) time.

2. Take a floating point number as input and replace the after decimal and before decimal parts by reverse of
before decimal and reverse of after decimal respectively. Example: if n=243.12 then ans=21.342, if
n=654.976 then ans=679.456

3. Write a program to input a positive integer n and check if it can be expressed as A^P where P > 1 and A > 0.
A and P both should be integers. Example; if n=8 then output=yes(8=2^3), if n=18 then output=no.

You might also like