MCA DSA Assignment 2024 Pattern – 35 Questions and Solutions in Python | SPPU
Are you an MCA First Year Semester 1 student looking for DSA Assignment questions and solutions in Python according to the SPPU 2024 Pattern? You are at the right place.
In this post, we are sharing 35 Data Structures and Algorithms (DSA) assignment questions with Python solutions for MCA FY Semester 1 students. The programs are written using simple and beginner-friendly Python logic so that students can understand, practice and prepare their practical assignments easily.
Along with the individual questions and solutions, we have also provided a ZIP file containing all 35 Python programs so that students can download and keep the complete DSA assignment in one place.
![]() |
Course: Data Structures and Algorithms (DSA)
Program: Master of Computer Applications (MCA)
Year: First Year
Semester: Semester 1
Pattern: SPPU 2024 Pattern
Programming Language: Python
Total Programs: 35
Table of Contents
- About This DSA Assignment
- 35 DSA Questions and Solutions
- Array Programs
- Matrix Programs
- Linked List Programs
- Download All 35 Python Programs
- Topics Covered
- DSA Practical Preparation Tips
- Frequently Asked Questions
About MCA DSA Assignment – SPPU 2024 Pattern
Data Structures and Algorithms is an important subject for MCA students. DSA helps students understand how data is stored, organized, accessed and processed efficiently.
This MCA DSA Assignment contains 35 practical questions implemented in Python programming language. The collection mainly focuses on arrays, matrices, singly linked lists and doubly linked lists along with common operations such as insertion, deletion, searching, traversal, merging and counting.
The programs are designed with simple logic to make them easier for MCA FY Semester 1 students to understand and practice.
35 DSA Assignment Questions and Python Solutions
Below is the complete list of 35 DSA assignment questions. The questions cover basic and commonly practiced Data Structures and Algorithms operations.
Array Programs in Python
1. Insert an Element in an Array
Write a python code to insert element in array
arr = [10, 20, 30, 40, 50]
element = int(input("Enter element: "))
position = int(input("Enter position: "))
n = 5
new_arr = [0] * 6
i = 0
while i < position:
new_arr[i] = arr[i]
i = i + 1
new_arr[position] = element
i = position
while i < n:
new_arr[i + 1] = arr[i]
i = i + 1
print("Array after insertion:")
i = 0
while i < 6:
print(new_arr[i], end=" ")
i = i + 1
2. Update an Element at a Given Index
Write a Program to update/modify an element at a given index.
arr = [10, 20, 30, 40, 50]
index = int(input("Enter index: "))
new_value = int(input("Enter new value: "))
arr[index] = new_value
print("Updated array:")
i = 0
while i < 5:
print(arr[i], end=" ")
i = i + 1
3. Search an Element in Array – Linear Search
Write a python code to search element in array(linear search)
n = int(input("Enter number of elements: "))
arr = [0] * n
i = 0
while i < n:
arr[i] = int(input("Enter element: "))
i = i + 1
search = int(input("Enter element to search: "))
i = 0
found = 0
while i < n:
if arr[i] == search:
found = 1
break
i = i + 1
if found == 1:
print("Element found at index:", i)
else:
print("Element not found")
4. Count Elements in an Array
Write a program to count elements in array
n = int(input("Enter number of elements: "))
arr = [0] * n
i = 0
while i < n:
arr[i] = int(input("Enter element: "))
i = i + 1
count = 0
i = 0
while i < n:
count = count + 1
i = i + 1
print("Number of elements:", count)
5. Delete an Element from an Array
Write a program to delete element from array
n = int(input("Enter number of elements: "))
arr = [0] * n
i = 0
while i < n:
arr[i] = int(input("Enter element: "))
i = i + 1
position = int(input("Enter position to delete: "))
i = position
while i < n - 1:
arr[i] = arr[i + 1]
i = i + 1
n = n - 1
print("Array after deletion:")
i = 0
while i < n:
print(arr[i], end=" ")
i = i + 1
6. Find Sum of Array Elements
Write a python code to find the sum of all elements.
n = int(input("Enter number of elements: "))
arr = [0] * n
for i in range(n):
arr[i] = int(input("Enter element: "))
sum = 0
for i in range(n):
sum = sum + arr[i]
print("Sum of all elements:", sum)
7. Find Frequency of an Element
Write a Python program to find the frequency of a particular element in an array.
n = int(input("Enter number of elements: "))
arr = [0] * n
for i in range(n):
arr[i] = int(input("Enter element: "))
for i in range(n):
count = 0
for j in range(n):
if arr[i] == arr[j]:
count = count + 1
print(arr[i], "=", count)
8. Find Average of Array Elements
Write a Python program to calculate the average of elements stored in an array.
n= int(input("Enter number of elements: "))
arr = [0] * n
for i in range(n):
arr[i] = int(input("Enter element: "))
sum = 0
for i in range(n):
sum = sum + arr[i]
average = sum / n
print("Average of array elements:", average)
9. Merge Two Arrays
Write a Python program to merge two arrays into a single array.
n1 = int(input("Enter size of first array: "))
a = [0] * n1
for i in range(n1):
a[i] = int(input("Enter element: "))
n2 = int(input("Enter size of second array: "))
b = [0] * n2
for i in range(n2):
b[i] = int(input("Enter element:" \
" "))
c = [0] * (n1 + n2)
for i in range(n1):
c[i] = a[i]
for i in range(n2):
c[n1 + i] = b[i]
print("Merged array:")
for i in range(n1 + n2):
print(c[i], end=" ")
10. Find Common Elements in Two Arrays
Write a Python program to find common elements between two arrays.
n1 = int(input("Enter size of first array: "))
a = [0] * n1
for i in range(n1):
a[i] = int(input("Enter element: "))
n2 = int(input("Enter size of second array: "))
b = [0] * n2
for i in range(n2):
b[i] = int(input("Enter element: "))
print("Common elements:")
for i in range(n1):
for j in range(n2):
if a[i] == b[j]:
print(a[i], end=" ")
11. Find Duplicate Elements in an Array
Write a Python program to find duplicate elements present in an array.
n = int(input("Enter number of elements: "))
a = [0] * n
for i in range(n):
a[i] = int(input("Enter element: "))
print("Duplicate elements:")
for i in range(n):
for j in range(i + 1, n):
if a[i] == a[j]:
print(a[i], end=" ")
12. Find Maximum and Minimum Element
Write a Python program to find the maximum and minimum elements in an array.
n = int(input("Enter number of elements: "))
a = [0] * n
for i in range(n):
a[i] = int(input("Enter element: "))
maximum = a[0]
minimum = a[0]
for i in range(1, n):
if a[i] > maximum:
maximum = a[i]
if a[i] < minimum:
minimum = a[i]
print("Maximum element:", maximum)
print("Minimum element:", minimum)
13. Fibonacci Series Using Array
Write a Python program to generate Fibonacci series using array elements.
a = [0, 1, 0, 0, 0]
for i in range(2, 5):
a[i] = a[i - 1] + a[i - 2]
print("Fibonacci series up to 5 numbers:")
for i in range(5):
print(a[i], end=" ")
14. Reverse an Array
Write a Python program to display the elements of an array in reverse order.
n = int(input("Enter number of elements: "))
a = [0] * n
for i in range(n):
a[i] = int(input("Enter element: "))
print("Reverse array:")
for i in range(n - 1, -1, -1):
print(a[i], end=" ")
15. Perform Operations on a 2D Array
Write a Python program to perform basic operations using a two-dimensional array.
r = int(input("Enter number of rows: "))
c = int(input("Enter number of columns: "))
a = [[0] * c for i in range(r)]
for i in range(r):
for j in range(c):
a[i][j] = int(input("Enter element: "))
print("2D Array:")
for i in range(r):
for j in range(c):
print(a[i][j], end=" ")
print()
Matrix Programs in Python
Matrix operations are useful for understanding two-dimensional arrays and are an important part of programming practice.
16. Matrix Addition
Write a Python program to add two matrices.
r = int(input("Enter rows: "))
c = int(input("Enter columns: "))
a = [[0] * c for i in range(r)]
b = [[0] * c for i in range(r)]
print("Enter first matrix:")
for i in range(r):
for j in range(c):
a[i][j] = int(input("Enter element: "))
print("Enter second matrix:")
for i in range(r):
for j in range(c):
b[i][j] = int(input("Enter element: "))
print("Addition:")
for i in range(r):
for j in range(c):
print(a[i][j] + b[i][j], end=" ")
print()
17. Matrix Subtraction
Write a Python program to subtract one matrix from another matrix.
r = int(input("Enter rows: "))
c = int(input("Enter columns: "))
a = [[0] * c for i in range(r)]
b = [[0] * c for i in range(r)]
print("Enter first matrix:")
for i in range(r):
for j in range(c):
a[i][j] = int(input("Enter element: "))
print("Enter second matrix:")
for i in range(r):
for j in range(c):
b[i][j] = int(input("Enter element: "))
print("Subtraction:")
for i in range(r):
for j in range(c):
print(a[i][j] - b[i][j], end=" ")
print()
18. Matrix Multiplication
Write a Python program to multiply two matrices.
r = int(input("Enter rows: "))
c = int(input("Enter columns: "))
a = [[0] * c for i in range(r)]
b = [[0] * c for i in range(r)]
result = [[0] * c for i in range(r)]
print("Enter first matrix:")
for i in range(r):
for j in range(c):
a[i][j] = int(input("Enter element: "))
print("Enter second matrix:")
for i in range(r):
for j in range(c):
b[i][j] = int(input("Enter element: "))
for i in range(r):
for j in range(c):
for k in range(c):
result[i][j] = result[i][j] + a[i][k] * b[k][j]
print("Multiplication:")
for i in range(r):
for j in range(c):
print(result[i][j], end=" ")
print()
19. Transpose of a Matrix
Write a Python program to find the transpose of a given matrix.
r = int(input("Enter rows: "))
c = int(input("Enter columns: "))
a = [[0] * c for i in range(r)]
print("Enter matrix:")
for i in range(r):
for j in range(c):
a[i][j] = int(input("Enter element: "))
print("Transpose:")
for j in range(c):
for i in range(r):
print(a[i][j], end=" ")
print()
20. Sum of Diagonal Elements
Write a Python program to calculate the sum of diagonal elements of a matrix.
n = int(input("Enter size of matrix: "))
a = [[0] * n for i in range(n)]
for i in range(n):
for j in range(n):
a[i][j] = int(input("Enter element: "))
sum = 0
for i in range(n):
sum = sum + a[i][i]
print("Sum of diagonal elements:", sum)
Linked List Programs in Python
Linked lists are fundamental data structures used to understand dynamic data organization. The following programs cover basic operations on Singly Linked List (SLL) and Doubly Linked List (DLL).
21. Insert Node at Last in Singly Linked List
Write a Python program to insert a new node at the end of a singly linked list.
n = int(input("Enter number of elements: "))
head = None
last = None
for i in range(n):
data = int(input("Enter element: "))
new = [data, None]
if head == None:
head = new
last = new
else:
last[1] = new
last = new
print("Linked List:")
p = head
while p != None:
print(p[0], end=" -> ")
p = p[1]
print("None")
22. Sum of Alternate Nodes in Doubly Linked List
Write a Python program to find the sum of alternate nodes in a doubly linked list.
n = int(input("Enter number of nodes: "))
a = [0] * n
for i in range(n):
a[i] = int(input("Enter element: "))
sum = 0
for i in range(0, n, 2):
sum = sum + a[i]
print("Sum of alternate nodes:", sum)
23. Reverse a Singly Linked List
Write a Python program to reverse a singly linked list.
n = int(input("Enter number of nodes: "))
a = [0] * n
for i in range(n):
a[i] = int(input("Enter element: "))
print("Reverse Linked List:")
for i in range(n - 1, -1, -1):
print(a[i], end=" ")
24. Delete Node from Beginning of SLL
Write a Python program to delete a node from the beginning of a singly linked list.
n = int(input("Enter number of nodes: "))
a = [0] * n
for i in range(n):
a[i] = int(input("Enter element: "))
print("After deleting first node:")
for i in range(1, n):
print(a[i], end=" ")
25. Reverse Nodes in Linked List
Write a Python program to reverse the nodes of a linked list.
n = int(input("Enter number of nodes: "))
a = [0] * n
for i in range(n):
a[i] = int(input("Enter element: "))
print("Original Linked List:")
for i in range(n):
print(a[i], end=" ")
print("\nReversed Linked List:")
for i in range(n - 1, -1, -1):
print(a[i], end=" ")
26. Delete Node Whose Sum is Zero
Write a Python program to delete a node whose sum is zero, including negative values where applicable.
n = int(input("Enter number of nodes: "))
a = [0] * n
for i in range(n):
a[i] = int(input("Enter element: "))
print("Linked List:")
for i in range(n):
print(a[i], end=" ")
print("\nAfter deleting elements whose sum is zero:")
i = 0
while i < n:
j = i + 1
while j < n:
if a[i] + a[j] == 0:
a[i] = 0
a[j] = 0
j = j + 1
i = i + 1
for i in range(n):
if a[i] != 0:
print(a[i], end=" ")
27. Create DLL and Count Nodes
Write a Python program to create a doubly linked list and count the total number of nodes.
n = int(input("Enter number of elements: "))
a = [0] * n
for i in range(n):
a[i] = int(input("Enter element: "))
count = 0
for i in range(n):
count = count + 1
print("Doubly Linked List:")
for i in range(n):
print(a[i], end=" <-> ")
print("None")
print("Count of elements:", count)
28. Search Element and Find Position in DLL
Write a Python program to search for an element in a doubly linked list and display its position.
n = int(input("Enter number of elements: "))
a = [0] * n
for i in range(n):
a[i] = int(input("Enter element: "))
search = int(input("Enter value to search: "))
for i in range(n):
if a[i] == search:
print("Value found at position:", i + 1)
break
else:
print("Value not found")
29. Remove Duplicates from Sorted SLL
Write a Python program to remove duplicate elements from a sorted singly linked list.
n = int(input("Enter number of elements: "))
a = [0] * n
for i in range(n):
a[i] = int(input("Enter element: "))
print("Linked List:")
for i in range(n):
if i == 0 or a[i] != a[i - 1]:
print(a[i], end=" ")
Example:
3 → 3 → 4 → 5
After removing duplicates:
3 → 4 → 5
30. Insertion and Deletion in SLL
Write a Python program to perform insertion and deletion operations in a singly linked list.
n = int(input("Enter number of elements: "))
a = [0] * (n + 1)
for i in range(n):
a[i] = int(input("Enter element: "))
# Insertion
pos = int(input("Enter position to insert: "))
value = int(input("Enter value: "))
for i in range(n, pos - 1, -1):
a[i] = a[i - 1]
a[pos - 1] = value
n = n + 1
print("After insertion:")
for i in range(n):
print(a[i], end=" ")
# Deletion
pos = int(input("\nEnter position to delete: "))
for i in range(pos - 1, n - 1):
a[i] = a[i + 1]
n = n - 1
print("After deletion:")
for i in range(n):
print(a[i], end=" ")
31. Count Nodes in SLL
Write a Python program to count the total number of nodes in a singly linked list.
n = int(input("Enter number of nodes: "))
a = [0] * n
for i in range(n):
a[i] = int(input("Enter element: "))
count = 0
for i in range(n):
count = count + 1
print("Number of nodes:", count)
32. Merge Two Sorted Singly Linked Lists
Write a Python program to merge two sorted singly linked lists into one sorted linked list.
n1 = int(input("Enter size of first list: "))
a = [0] * n1
for i in range(n1):
a[i] = int(input("Enter element: "))
n2 = int(input("Enter size of second list: "))
b = [0] * n2
for i in range(n2):
b[i] = int(input("Enter element: "))
c = [0] * (n1 + n2)
for i in range(n1):
c[i] = a[i]
for i in range(n2):
c[n1 + i] = b[i]
print("Merged List:")
for i in range(n1 + n2):
print(c[i], end=" ")
33. Insert Node at Specific Position
Write a Python program to insert a new node at a specific position in a linked list.
n = int(input("Enter number of elements: "))
a = [0] * (n + 1)
for i in range(n):
a[i] = int(input("Enter element: "))
pos = int(input("Enter position: "))
value = int(input("Enter value: "))
for i in range(n, pos - 1, -1):
a[i] = a[i - 1]
a[pos - 1] = value
print("After insertion:")
for i in range(n + 1):
print(a[i], end=" ")
34. Delete from Beginning and End in DLL
Write a Python program to delete nodes from the beginning and end of a doubly linked list.
n = int(input("Enter number of elements: "))
a = [0] * n
for i in range(n):
a[i] = int(input("Enter element: "))
# Delete from beginning
print("After deleting from beginning:")
for i in range(1, n):
print(a[i], end=" ")
# Delete from end
print("\nAfter deleting from end:")
for i in range(0, n - 1):
print(a[i], end=" ")
35. Merge Two Sorted Doubly Linked Lists
Write a Python program to merge two sorted doubly linked lists while maintaining sorted order.
n1 = int(input("Enter size of first list: "))
a = [0] * n1
for i in range(n1):
a[i] = int(input("Enter element: "))
n2 = int(input("Enter size of second list: "))
b = [0] * n2
for i in range(n2):
b[i] = int(input("Enter element: "))
c = [0] * (n1 + n2)
for i in range(n1):
c[i] = a[i]
for i in range(n2):
c[n1 + i] = b[i]
print("Merged Doubly Linked List:")
for i in range(n1 + n2):
print(c[i], end=" <-> ")
print("None")
Download All 35 DSA Python Programs
To make the assignment preparation easier, all 35 DSA Python programs are also available in a single ZIP file.
📥 Download DSA Assignment ZIP
Get all 35 MCA DSA assignment programs in Python in one ZIP file.
File Format: ZIP | Programs: 35 | Language: Python
Topics Covered in This DSA Assignment
``` ```| Topic | Programs |
|---|---|
| Arrays | 1 – 15 |
| 2D Arrays / Matrix | 15 – 20 |
| Singly Linked List | 21 – 33 |
| Doubly Linked List | 22, 27 – 29, 34 – 35 |
| Searching | Included |
| Insertion & Deletion | Included |
| Merging | Included |
How to Prepare for MCA DSA Practical
If you are preparing for your MCA Semester 1 DSA practical examination, do not only memorize the Python programs. Try to understand the logic behind every program.
1. Understand the Question
First identify which data structure is required and what operation the question is asking you to perform.
2. Understand the Algorithm
Before writing Python code, understand the steps required to solve the problem.
3. Write the Python Program
Try writing the program yourself after understanding the algorithm.
4. Check the Output
Run the program in VS Code or another Python IDE and verify the output.
5. Prepare for Viva
Be ready to explain basic concepts such as arrays, linked lists, nodes, traversal, insertion, deletion, searching and merging.
Important DSA Concepts for MCA Students
- Array
- Two-Dimensional Array
- Matrix
- Linear Search
- Array Traversal
- Singly Linked List
- Doubly Linked List
- Node
- Insertion
- Deletion
- Searching
- Reversal
- Merging
Why Learn DSA Using Python?
Python has simple and readable syntax, which makes it useful for beginners learning Data Structures and Algorithms. Students can focus more on understanding the algorithm and data structure instead of dealing with complicated programming syntax.
Practicing DSA using Python can also help MCA students improve their programming logic and problem-solving skills.
Frequently Asked Questions
What is MCA DSA Assignment?
MCA DSA Assignment is a practical collection of Data Structures and Algorithms programs prepared for MCA students to practice important data structure operations.
Is this DSA assignment for SPPU 2024 Pattern?
This collection is prepared for MCA First Year Semester 1 students following the SPPU 2024 Pattern.
Which programming language is used?
All 35 programs in this assignment are implemented using Python programming language.
How many programs are included?
This collection contains 35 DSA assignment questions and Python solutions.
Can I download all 35 programs together?
Yes. A ZIP file containing all 35 Python programs is provided above for easy downloading.
Are these programs useful for DSA practical preparation?
Yes. These programs can be used for learning, assignment practice, programming practice and DSA practical preparation.
Are the Python programs beginner-friendly?
Yes. The programs are written using simple Python logic so that beginners can understand the basic concepts of DSA.
Conclusion
This MCA DSA Assignment 2024 Pattern collection provides 35 practical questions and solutions covering arrays, matrices, singly linked lists and doubly linked lists.
MCA First Year Semester 1 students can use these DSA programs in Python to practice their assignments, improve programming logic and prepare for practical examinations and viva.
Download the complete ZIP file, practice each program and make sure you understand the logic behind the code instead of simply memorizing it.
If you find this SPPU MCA DSA Assignment useful, share it with your MCA classmates and help them with their DSA practical preparation.

0 Comments