Dept.
of Computer Science and Engineering (Artificial Intelligence)
B. Tech I Year II Semester
25BACSELC03 DATA STRUCTURES AND ALGORITHMS LABORATORY
L T P C
0 0 2 1
Pre-requisite C Programming for Problem Solving Laboratory
Course Description:
This course provides hands-on practice with fundamental data structures and algorithms using the C
programming language. Students will design and implement linear and non-linear data structures,
perform standard operations, and apply searching, sorting, and traversal techniques to solve real-world
problems.
Course Objectives:
This course enables students to
1. Implement core data structures and algorithms using C language.
2. Develop competency in linear structures (arrays, linked lists, stacks, queues) and their
operations.
3. Construct and manipulate non-linear structures (trees and graphs) with traversal techniques.
4. Analyze time and space complexity of implemented algorithms.
5. Apply suitable data structures to model and solve real-world problems.
List of Experiments:
1. (a) Given an integer array nums and an integer k (1 ≤ k ≤ len(nums)), return the kth largest
element in nums. The kth largest element is the element that would appear at index k−1 if the
array were sorted in descending order.
(b) Develop a program and compute the complexity analysis of reversing an one-dimensional
array of length n.
2. Implement a menu-driven application that manages patients in a Hospital Management System.
Each patient node should store relevant details (e.g., Patient ID, Name, Age, and
Ailment/Department). The program must support the following operations and demonstrate them
in sequence:
a. Add at least five patient records to the queue (rear insertion).
b. Delete the patient at the front of the queue (beginning).
c. Delete a patient from the middle of the queue (by Patient ID or position), ensuring list
integrity is maintained.
d. Search for a specific patient by a unique identifier (e.g., Patient ID) and display the
patient’s details if found.
Display the final state of the queue after performing the above operations, showing all remaining
patients in order.
49 | P a g e
Dept. of Computer Science and Engineering (Artificial Intelligence)
3. Build a menu-driven application that maintains a playlist where each node represents a song. The
program should support the following operations and demonstrate:
a. Add at least five songs to the playlist (tail insertion recommended).
b. Delete one song from the beginning (head deletion).
c. Delete one song from the middle (by Song ID or position), ensuring all links are
updated correctly.
d. Display the playlist in forward direction (head to tail).
e. Display the playlist in backward direction (tail to head).
Search for a particular song by its unique Song ID and display its details if found.
4. Implement a menu-driven application that manages page visits. Each entry represents a web
page. Demonstrate the following sequence within the program:
a. Start with an empty history stack.
b. Visit 5 pages by pushing their identifiers/URLs onto the stack.
c. Press “Back” twice by performing two pop operations.
5. Develop a Ticket Counter System for a cinema hall where customers are served in the same order
they arrive. Implement the following steps:
a. Add at least 5 customers to the queue.
b. Serve (dequeue) two customers.
c. Peek the next customer to be served.
d. Display the full waiting list.
6. Develop a menu-driven application that manages a directory tree. Each node stores:
a. int id (unique identifier)
b. int isFolder (1=folder, 0=file)
c. char name[...] (optional but recommended)
d. struct Node* left, *right
Implement the following tasks:
i. Insert at least seven nodes (file/folder IDs) into the tree. Use a consistent insertion
policy (by id).
ii. print all the traversal methods (Preorder, Inorder, Postorder).
iii. Search for a specific file/folder by ID and display whether it exists along with its
type (file/folder) and name if available.
iv. Delete a folder (by ID) from the tree. Ensure standard BST deletion behavior (0, 1, or
2 children) and maintain tree integrity.
v. Show the final directory structure using Inorder traversal with clear labeling.
7. Develop a program that simulates incoming player scores and maintains a descending (highest-
to-lowest) leaderboard using insertion sort. The program should:
a. Implement a function insertDescending(int arr[], int n, int newScore) that inserts
newScore into its correct position using insertion sort logic.
b. Print the leaderboard after each insertion with ranks.
8. Develop an application that accepts a set of athlete completion times recorded in random order
and arranges them in ascending order (smallest time = fastest).
50 | P a g e
Dept. of Computer Science and Engineering (Artificial Intelligence)
a. Use an array of integers or floats to store completion times.
b. Implement Selection Sort to order times in ascending order.
c. Print the list before and after sorting.
d. Display the top performers.
9. Design and implement a program that models a city’s bus transit network as an unweighted graph
and, given a starting stop, lists all reachable stops by minimum number of bus rides and computes
a shortest path (in hops) to a specified destination.
10. Design and implement a program that determines whether a given word exists in a 2D grid of
letters by performing Depth-First Traversal (DFT).
Course Outcomes:
After completion of the course, students will be able to
CO1: Implement the core array operations and analyze the time-space complexities.
CO2: Apply linear and non-linear data structures algorithms for the real-world problem solving
applications.
CO3: Construct and manipulate tree-based data structures—binary trees and binary search trees—and
perform traversal, insertion, and deletion operations.
CO4: Implement and compare sorting algorithms with respect to time and space complexity.
CO5: Apply graph traversal algorithms to explore and process graph structures.
Text Books:
1. Data Structures, Algorithms and Applications in C by Sartaj Sahni, McGraw Hill, NY, Second
Edition.
References Books:
1. Data Structures and Algorithm Analysis in C, Mark Allen Weiss, Pearson Education. Ltd., Second
Edition.
2. Data Structures and Algorithms, Alfred V. Aho, John E. Hopcroft, Jeffery [Link]. Pearson; 1st
Edition, 2002.
Mode of Evaluation: Continuous Internal Evaluation and Semester End Examination.
51 | P a g e