DSA Assignment-II
DSA Assignment-II
Assignment Sheet-II
Session 2024_25 (Odd Semester)
Set-I
Q.No Question BL CO MM
1 A company stores employee IDs in a Binary Search Tree (BST). 3 3 10
Each node represents an employee ID. Due to frequent searches and
additions, the tree becomes unbalanced. Illustrate how an AVL tree
could help maintain balance, and perform a rotation example on a set
of IDs [5, 3, 8, 2, 4, 7, 9,12,16,1] if needed.
4 You are given unsorted scores [43, 87, 12, 99, 58, 33, 27,45,66,50] 3 4 10
from a class test and need to display them in descending order for
award allocation. Apply the quicksort algorithm step-by-step to
arrange these scores. Also mention time complexity of all cases.
Swami Keshvanand Institute of Technology, Management &Gramothan, Jaipur
Department of Computer Science & Engineering
Assignment Sheet-II
Session 2024_25 (Odd Semester)
Q.No Question BL CO MM
1 An online library catalog system uses a B-Tree to store book records due 4 3 10
to its efficiency in handling large amounts of data. Illustrate how the B-
Tree would handle a large volume of book records, and show how a new
record with ID 36 is added to an existing B-Tree with nodes [20, 30, 40,
50,60,65,70,15].
2 A GPS navigation system needs to find the shortest route between two 3 3 10
locations. Demonstrate how Dijkstra's algorithm finds the shortest path,
and apply it step-by-step to find the shortest path on a simple weighted
graph.
4 A set of patient records [102, 88, 145, 36, 50, 77, 110, 37, 90, 86] need 3 4 10
to be sorted by admission date for proper queue management. Show
step-by-step how selection sort would organize these records. Also
mention time complexity of all cases.
Swami Keshvanand Institute of Technology, Management &Gramothan, Jaipur
Department of Computer Science & Engineering
Assignment Sheet-II
Session 2024_25 (Odd Semester)
Q.No Question BL CO MM
1 Demonstrate how in-order, pre-order, and post-order traversal techniques 3 3 10
would be used in a medical imaging storage system (such as MRI scan
data). If given a binary tree with nodes [A, B, C, D, E, F, G, H, I, J, K],
perform an in-order, pre-order, and post-order traversal and list the output
sequence.
Assignment Sheet-II
Session 2024_25 (Odd Semester)
SET-IV
Q.No Question BL CO MM
1 A video game uses a Binary Search Tree to manage in-game items 4 3 10
by rarity levels. Analyze how a BST would optimize the search for
a specific rarity level and perform insertion of items [10, 5, 15, 2, 7,
12, 17,20,18, 6, 9] into a BST.
4 Show how heap sort can be used to order priority tasks in a to-do 3 4 10
list [20, 50, 10, 5, 15, 40, 35,45]. Provide a step-by-step solution to
sort this list. Also mention time complexity of all cases.
Swami Keshvanand Institute of Technology, Management &Gramothan, Jaipur
Department of Computer Science & Engineering
Assignment -II
Session 2024_25 (Odd Semester)
SET-V
Q.No Question BL CO MM
1 Analyze how a self-balancing AVL tree can improve search 4 3 10
efficiency in an online ticket reservation system. Given the sequence
[30, 20, 40, 10, 25, 35, 50], draw the AVL tree after each insertion,
indicating any rotations required.
4 Apply radix sort to arrange employee ID numbers [170, 45, 75, 90, 3 4 10
802, 24, 2, 66, 55, 96, 672] in ascending order and show the
sorting stages. Also mention time complexity of all cases.
Swami Keshvanand Institute of Technology, Management &Gramothan, Jaipur
Department of Computer Science & Engineering
Assignment Sheet-II
Session 2024_25 (Odd Semester)
SET-VI
Q.No Question BL CO MM
1 Explain how a Binary Tree can be used to represent and analyze the 4 3 10
structure of a file directory. Using a sample structure with folders
and subfolders as nodes, performing pre-order and in-order traversal
to print the folder names in sequence.
4 Describe the bubble sort method by sorting a list of daily sales [33, 3 4 10
15, 17, 29, 10, 45, 20, 25, 60, 12, 19] in ascending order. Show each
swap step by step until the list is fully sorted. Explain the use of
hashing in organizing data in a digital library system. Also mention
time complexity of all cases.
Swami Keshvanand Institute of Technology, Management &Gramothan, Jaipur
Department of Computer Science & Engineering
Assignment Sheet-II
Session 2024_25 (Odd Semester)
SET-VII
Q.No Question BL CO MM
1 In an online ordering system, customer orders are organized based 3 3 10
on urgency levels. If each order's urgency level is represented as a
node in an AVL Tree, explain how balancing the tree after each new
order improves retrieval efficiency. Insert the urgency levels [30,
15, 40, 10, 25, 35, 50] step-by-step, showing the AVL tree structure
and rotations after each insertion.
Assignment Sheet-II
Session 2024_25 (Odd Semester)
(Set-VIII)
Q.No Question BL CO MM
1 You are given a Binary Search Tree (BST) containing the 3 3 10
elements [50, 30, 70, 20, 40, 60, 80]. Write a function to find the
Lowest Common Ancestor (LCA) of two nodes in this BST. The
function should efficiently compute the LCA when given two
node values (e.g., 20 and 40). Demonstrate your approach and
provide the time complexity.
Assignment Sheet-II
Session 2024_25 (Odd Semester)
(Set-IX)
Q.No Question BL CO MM
1 You are tasked with designing an AVL Tree to maintain a dynamic 3 3 10
set of customer records where the key is the customer ID. Insert the
following customer IDs into an initially empty AVL Tree: [10, 20,
30, 25, 28, 27, 5]. Show the AVL Tree after each insertion,
including any necessary rotations.
Use a stack to simulate the DFS and provide the order in which the
nodes are visited. If two nodes have the same discovery time,
prioritize alphabetically.
Assignment Sheet-II
Session 2024_25 (Odd Semester)
3 An array has the following elements: [54, 26, 93, 17, 77, 31, 44, 55, 3 4 10
20]. Demonstrate the steps involved in searching for the number 77
using binary search. First, sort the array and then proceed with the
binary search steps.
Assignment Sheet-II
Session 2024_25 (Odd Semester)
(Set-XI)
Q.No Question BL CO MM
1 You are given a list of numbers: [20, 10, 30, 5, 15, 25, 35]. Construct 3 3 10
a Binary Search Tree (BST) from this list. After constructing the
tree, perform an in-order, pre-order, and post-order traversal, and
provide the output for each traversal.
2 Consider a connected undirected graph represented by the 3 3 10
following adjacency matrix:
4 Sort the following array using Quick Sort: [29, 10, 14, 37, 14]. Show 3 4 10
each step of the sorting process, including the selection of the pivot
element at each stage.
Swami Keshvanand Institute of Technology, Management &Gramothan, Jaipur
Department of Computer Science & Engineering
Assignment Sheet-II
Session 2024_25 (Odd Semester)
(Set-XII)
Q.No. Question BL CO MM
1 A database needs to store records in a balanced tree structure for 4 3 10
efficient search, insertion, and deletion operations. Justify why an
AVL Tree or a B-Tree is more suitable for this purpose than a
normal binary search tree (BST). Provide a real-life example
where this might be used.
Assignment Sheet-I
Session 2024_25 (Odd Semester)
(Set-XIII)
Q. Question BL CO MM
No.
1 Given a Binary Tree that represents a file directory structure, write an 3 3 10
algorithm to convert this Binary Tree into its mirror image (left and
right children of all nodes are swapped). For example, given the tree:
mirror image →
2 Construct the minimum spanning tree (MST) for the given graph 3 3 10
using Kruskal’s Algorithm. Also find total weight of the MST.
3 Consider an array of product IDs [45, 23, 89, 12, 78, 67, 49]. 3 4 10
Implement a binary search algorithm to find whether the product ID
67 exists in the array. First, sort the array using any sorting algorithm,
then apply binary search. Explain each step of the binary search
process.