Jawaharlal Nehru Technological University Hyderabad
Jawaharlal Nehru Technological University Hyderabad MCA 2020 DATA STRUCTURES AND ALGORITHMS Previous Question Paper (October/ November - 2020 - R17)
Answer any five questions
All questions carry equal marks
Main
Write an algorithm to implement Merge sort applying Divide and Conquer method.
Answer
Merge sort follows the divide and conquer paradigm by recursively splitting an array into halves until individual elements remain, then merging them in sorted order.
- Divide: Find the midpoint m = (left + right) / 2.
- Conquer: Recursively call MergeSort for the left subarray (left to m) and the right subarray (m + 1 to right).
- Combine: Merge the two sorted subarrays into a single sorted array using a temporary array.
Algorithm MergeSort(A, left, right):
if left < right:
mid = (left + right) / 2
MergeSort(A, left, mid)
MergeSort(A, mid + 1, right)
Merge(A, left, mid, right)Apply Merge Sort to sort the following elements in the ascending order: 20, 12, 14, 85, 94, 45, 74, 33, 25, 67.
Answer
To sort the list [20, 12, 14, 85, 94, 45, 74, 33, 25, 67], we divide recursively:
1. Split into [20, 12, 14, 85, 94] and [45, 74, 33, 25, 67].
2. Further split until single elements: [20], [12], [14], [85], [94], [45], [74], [33], [25], [67].
3. Merge pairs:
- [12, 20], [14, 85], [94], [45, 74], [25, 33], [67]
- [12, 14, 20, 85], [45, 94], [25, 33, 67, 74]
- [12, 14, 20, 45, 85, 94], [25, 33, 67, 74]
- Final Merge: [12, 14, 20, 25, 33, 45, 67, 74, 85, 94]
The sorted list is: 12, 14, 20, 25, 33, 45, 67, 74, 85, 94.
Write an algorithm for Prim’s algorithm to find minimum cost spanning tree.
Answer
Sign in to view the complete answer paper.
Write the General method for Backtracking design method.
Answer
Sign in to view the complete answer paper.
Write an algorithm to N-Queens problem and explain with an example of considering 4*4 chess board.
Answer
Sign in to view the complete answer paper.
Write an algorithm for Insertion sort technique and apply it for arranging the following elements in ascending order: 25, 77, 88, 54, 96, 32, 14, 59, 64.
Answer
Sign in to view the complete answer paper.
Write algorithms to implement Skip lists operations: insertion and deletion.
Answer
Sign in to view the complete answer paper.
Define a Binary Tree and write the applications of binary trees.
Answer
Sign in to view the complete answer paper.
Write an algorithm for Depth First Search (DFS) traversal of a graph and give an example.
Answer
Sign in to view the complete answer paper.
Explain Strassen’s matrix multiplication.
Answer
Sign in to view the complete answer paper.
Write an algorithm for Binary search. Give its time complexity analysis.
Answer
Sign in to view the complete answer paper.
Let n=5, (p1…..p5) = (20, 15, 10, 5, 1) and (d1…d5) = (2, 2, 1, 3, 3). Find out an optimal solution for given job sequence with deadlines problem using Greedy method.
Answer
Sign in to view the complete answer paper.
Write the General method for Dynamic programming.
Answer
Sign in to view the complete answer paper.
Let n=4 and {a1, a2, a3, a4} = {do, if, int, while}. Let p[1…4]={3, 3, 1, 1} and q[0..4]={2,3,1,1,1} construct the optimal binary search tree.
Answer
Sign in to view the complete answer paper.