0% found this document useful (0 votes)
124 views16 pages

DSA Assignment

Uploaded by

Ramya Ambekar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
124 views16 pages

DSA Assignment

Uploaded by

Ramya Ambekar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

RV COLLEGE OF ENGINEERING®

(Autonomous Institution Affiliated to VTU, Belagavi)


R.V. Vidyanikethan, Bengaluru-560059

DEPARTMENT OF MASTER OF COMPUTER APPLICATIONS

Assignment
II Semester
Data Structures and Algorithms (20MCA22)

Submitted by

Group 15
ASHISH BISHT 1RV20MC012
RAMYA R AMBEKAR 1RV20MC084

PRAVEEN M 1RV20MC073
KALLAMMANAVAR
LIKITHA S 1RV20MC037

September-2021

RV COLLEGE OF ENGINEERING®
(Autonomous Institution Affiliated to VTU, Belagavi)
R.V. Vidyanikethan, Bengaluru-560059
DEPARTMENT OF MASTER OF COMPUTER APPLICATIONS

CERTIFICATE

This is to certify that have successfully completed ASHISH BISHT 1RV20MC012, RAMYA
R AMBEKAR 1RV20MC084, PRAVEEN M KALLAMMANAVAR 1RV20MC073,
LIKITHA S 1RV20MC037 Assignment on Data Structures and Algorithms (20MCA22) in
partial fulfillment of II semester MCA for the academic year 2020-2021.

MARKS
USN Name Max Assignment – Assignment - Final
Marks 1 2 Marks
1RV20MC012 ASHISH BISHT
1RV20MC084 RAMYA R
AMBEKAR
1RV20MC073 PRAVEEN M 30
KALLAMMANAVAR
1RV20MC037 LIKITHA S

Faculty In-charge Director, MCA


Prof. Savita Sheelavant Dr. Andhe Dharani
Assistant Professor Professor and Director
Department of MCA Department of MCA
RV College of Engineering® RV College of Engineering®
Bengaluru – 560059 Bengaluru – 560059
Question 1) identify the different data structures and various
design techniques used to solve the given problem

Ans:- Data structure Used- Arrays


Design techniques used- 1- Space optimized method
2- Power of Matrix

Question 2) Analyze and obtain the time complexity of the


problem for the identified design techniques and data
structures used
Question 3) Implement and Demonstrate the problem

Space Optimized Method

def fibonacci(n):
a=0
b=1
if n < 0:
print("Incorrect input")
elif n == 0:
return a
elif n == 1:
return b
else:
for i in range(2,n+1):
c=a+b
a=b
b=c
return b
num=int(input(“Enter the number:”))
print(fibonacci(num))
Using power of the matrix {{1, 1}, {1, 0}}

def fib(n):
F = [[1, 1], [1, 0]]
if (n == 0):
return 0
power(F, n - 1)
return F[0][0]

def multiply(F, M):


x = (F[0][0] * M[0][0] +
F[0][1] * M[1][0])
y = (F[0][0] * M[0][1] +
F[0][1] * M[1][1])
z = (F[1][0] * M[0][0] +
F[1][1] * M[1][0])
w = (F[1][0] * M[0][1] +
F[1][1] * M[1][1])

F[0][0] = x
F[0][1] = y
F[1][0] = z
F[1][1] = w

def power(F, n):


M = [[1, 1], [1, 0]]
for i in range(2, n + 1):
multiply(F, M)
if __name__ == "__main__":
n = int(input(“Enter the number:”))
print(fib(n))
Queston 4) Justify and evaluate the implemented design techniques.
Question 5) Find the order of growth for the following
recurrence relations:
a) x(n) = x(n/4) + n for n > 1, x(1) = 1
b) x(n) = x(n/2) + n for n > 1, x(1) = 1
Question 6) Complete the given table for the course content of
DSA

Sl. Problem Algorithm Time Complexity


No Technique Worst Average Best
Key element Key element is Key element
found at last at other than found at first
position. first and last position.
1. Linear Search Brute Force
position.

O(n) O(n/2) O(1)


The binary
The binary search finds the
The first
search finds item at the
comparison is
the item at the element in
correct(the
end of the list between the list
Divide and key item is
2. Binary Search
Conquer equal to the
mid of array).

O(1)
ϴ(log2n)
ϴ(log2n)

Divide and
3. Merge Sort O(nlog2n) ϴ(nlog2n) O(nlog2n)
Conquer

The partition
The partition The average process
process always case of always picks
picks greatest quicksort is not the middle
or smallest when the pivot element as
Divide and
4. Quick Sort element as is the median pivot.
Conquer
pivot. element.

O(n2) ϴ(nlog2n) O(nlog2n)


Topological
5 BFS and DFS
Order

Dijkstra’s Θ(E+V log


6. Greedy O(N2) Θ(E+V log V)
Algorithm V)

Prim’s O((V+E)log
7. Greedy - -
Algorithm V)

Floyd–
Dynamic
8. WarshallAlgor O(n3) O(n3) O(n3)
Programming
ithm

You might also like