PRASAD V POTLURI
SIDDHARTHA INSTITUTE OF TECHNOLOGY, KANURU,
VIJAYAWADA
LAB EXTERNAL QUESTION PAPER
Subject: Data Structures Lab Code: 23IT3251
Year: I [Link] – II Sem Reg: PVP23 A.Y:2025-26
Branch: Information Technology Section: S1 Date: 25-06-2026
Set – 1
Q1. Given an array "nums" with n objects colored red, white, or blue, sort them in place so
that objects of the same color are adjacent, with the colors in the order red, white, and blue.
We will use the integers 0, 1, and 2 to represent the color red, white, and blue, respectively.
Write a program to solve this problem using the Selection sort algorithm.
Q2. Ram has given an array of integers representing the ages of people in a group. Ram's task
is to implement a linear search algorithm in C to find if a given age exists in the array and
return its index.
Q3. You are working as a software engineer for a bus ticketing system. The system needs to
handle ticket requests efficiently. Each request arrives at the system with a timestamp
representing the time when the request was made. To process these requests in the correct
order, you need to sort them by their timestamps before handling [Link] task is to write a
program that reads a list of ticket request timestamps, sorts them in ascending order, and then
prints the sorted list. The queue of ticket requests will be implemented using a linked list.
Set – 2
Q1. Arun is tasked with implementing a program to reverse a singly linked list. The program
should populate the list elements by inserting them at the beginning, traverse the list and
reverse the order of its [Link] Arun is new to programming, you have to guide him
through the task.
Q2. SELECTION SORT
It's the first day for the students at school and the students enter the class and get seated at
random places without any height order. So the students who are short and sitting back are
not able to see the board since they sit behind taller students. Understanding this difficulty,
the teacher decides to make the students sit in height order. Suppose there are n students in
the class. She makes all the students stand in a line and compares the first student's height
with the remaining (n-1) students. If the first student's height is greater than the ith student,
then the taller person goes to the ith place and the i'th student comes to the first place. Again
the new first student's height is compared with the remaining students and if his height is
greater than ith student the first student goes to ith place and ith place student comes to first
place and this goes on till the end. This process continues for all the students. Finally, the
students are in height [Link] a program to perform selection sort on an array of n
elements.
Q3. Aishu is participating in a coding challenge where she needs to reconstruct a Binary
Search Tree (BST) from given preorder traversal data and then print the in-order traversal of
the reconstructed BST. Since Aishu is just learning about tree data structures, she needs your
help to write a program that does this efficiently.
Set – 3
Q1. Ashwin is tasked with developing a simple application to manage a list of items in a shop
inventory using a doubly linked list. Each item in the inventory has a unique identification
number. The application should allow users to perform the following operations:
Create a List of Items: Initialize the inventory with a given number of items. Each
item will be assigned a unique number provided by the user and insert the elements at
end of the list.
Delete an Item: Remove an item from the inventory at a specific position.
Display the Inventory: Show the list of items before and after deletion.
If the position provided for deletion is invalid (e.g., out of range), it should display an
error message.
Q2. Anu needs to remove duplicate elements from singly linked lists. She wants a program
that takes multiple linked lists as input at the end, removes duplicates from each linked list,
and outputs the modified linked lists.
Q3. Chandra is a cyclist who loves collecting data about her bike rides. She has a collection
of bike ride data in the form of speeds (in km/h) that she wants to store in a hash table.
However, she is concerned about efficiently storing this data using quadratic probing, a
collision resolution technique. Write a program to help Chandra find the fastest bike speed
along with its index in the hash table (table size 10). For each bike, calculate a hash index
using the modulo operation (% tableSize).
Set – 4
Q1. Priya is designing a supermarket checkout queue system to efficiently manage customer
flow. Customers join the queue, and cashiers process their orders. Her goal is to implement
the core functionality of this system using a queue data structure with an array with the
following operations:
1. Add Customer to Queue: Add a customer to the checkout queue. A unique customer
ID identifies each customer.
2. Delete Customer: Remove the customer at the front of the queue.
3. Display Queue: Display the customer IDs of all customers in the queue.
Help her in designing the program.
Q2. Akila is a tech enthusiast and wants to write a program to add two polynomials. Each
polynomial is represented as a linked list, where each node in the list represents a term in the
polynomial. A term in the polynomial is represented in the format ax^b, where a is the
coefficient and b is the [Link] needs your help to implement a program that takes
two polynomials as input, adds them, and stores the result in ascending order in a new
polynomial-linked list. Write a program to help her.
Q3. Sarah, an event organizer, is in need of a program to efficiently manage guest lists for her
events using linear search algorithm. She wants a tool that allows her to input a list of
attendees and a set of keys (representing guest IDs) that she wants to search for. The program
should identify the positions of the keys in the attendee list or notify Sarah if any of the keys
are not found in the list.
Set – 5
[Link] is learning about binary search trees and their traversal techniques. He wants to implement a
program that constructs a binary search tree by inserting nodes and then performs a level order
traversal on the binary search tree.
Q2. Aarav is working on a program to analyze his test scores, which are stored in a doubly linked list.
He needs a solution to input scores into the list and determine the highest score. Help him by
providing code that lets users enter test scores into the doubly linked list and find the maximum score
efficiently.
Q3. Lena, a financial analyst, needs to sort daily profit and loss values for a stock portfolio, which can
be either positive or negative. Using a bubble sorting technique, she must arrange these values in
ascending order. Help Lena ensure the profit and loss values are sorted accurately.
Set – 6
Q1. Develop a program using hashing to manage a fruit contest where each fruit is assigned a
unique name and a corresponding score. The program should allow the organizer to input the
number of fruits and their names with scores. Then, it should enable them to check if a
specific fruit, identified by its name, is part of the contest. If the fruit is registered, the
program should display its score; otherwise, it should indicate that it is not included in the
contest.
Q2. Write a program that evaluates a postfix expression and calculates its result. The
expression can contain digits and operators (+, -, *, /), and may or may not have spaces
between them. If an invalid operator is encountered, display an error message.
Q3. Anu needs to remove duplicate elements from singly linked lists. She wants a program
that takes multiple linked lists as input at the end, removes duplicates from each linked list,
and outputs the modified linked lists.
Set – 7
Q1. You are a software developer working on a program to process data from a sensor
network. The sensor network collects readings from various sensors placed at different
locations. Each sensor reading is stored in an integer array. Your task is to write a C program
that reverses the order of the elements in the array, so that the most recent sensor reading
becomes the first element, and the oldest reading becomes the last element. Write a C
program to reverse the elements of an integer array
[Link] are tasked with implementing a simple queue data structure using a linked list. The
queue should support the following operations:
1. Enqueue: Add an integer element to the end of the queue.
2. Dequeue: Remove and discard the element from the front of the queue.
3. Display: Display the elements currently in the queue, from front to rear.
Your task is to implement these operations and create a program that demonstrates their
functionality.
Q3. Imagine you are managing the backend of an e-commerce platform. Customers place
orders at different times, and the orders are stored in two separate linked lists. The first list
holds the orders from morning, and the second list holds the orders from the evening. Your
task is to merge the two lists so that the final list holds all orders in sequence from the
morning list followed by the evening orders, in the same order
Set – 8
Q1. Hasini is studying polynomials in her class. Her teacher has introduced a new concept of two
polynomials using linked lists. The teacher provides Hasini with a program that takes two
polynomials as input, represented as linked lists, and then displays them together. The polynomials
are simplified and should be displayed in the format ax^b, where a is the coefficient and b is the
exponent.
Q2. You are working as a software engineer for a bus ticketing system. The system needs to handle
ticket requests efficiently. Each request arrives at the system with a timestamp representing the time
when the request was made. To process these requests in the correct order, you need to sort them by
their timestamps before handling them. Your task is to write a program that reads a list of ticket
request timestamps, sorts them in ascending order, and then prints the sorted list. The queue of ticket
requests will be implemented using a linked list.
Q3. Imagine Anu is tasked with finding the middle element of a doubly linked list. Given a doubly
linked list where each node contains an integer value and is inserted at the end, implement a program
to find the middle element of the list. If the number of nodes is even, return the middle element pair.
Set – 9
Q1. Rohit is given the role of designing a programming challenge for an educational
platform. The challenge involves creating a program that performs the functionality of a stack
data structure, implemented using an array. The main objective of this challenge is to develop
a menu-driven program that empowers users to execute a range of stack operations, which
include adding elements to the stack, removing elements from the stack, and visualizing the
current contents of the stack. Write a program to help Rohit design the programming
challenge.
Q2. Aishu is participating in a coding challenge where she needs to reconstruct a Binary
Search Tree (BST) from given preorder traversal data and then print the in-order traversal of
the reconstructed BST. Since Aishu is just learning about tree data structures, she needs your
help to write a program that does this efficiently.
Q3. Akash developed by simulating a circular queue with a condition for enqueuing
elements. The queue accepts only numbers that are multiples of 3 or 5. Your program should
handle the following operations:
1. Enqueue Operation: Adds an element to the queue, but only if it is a multiple of 3 or
5. If the value is not a multiple of 3 or 5, print a message indicating it's invalid.
2. Dequeue Operation: Removes an element from the front of the queue. If the queue is
empty, print "Queue Underflow".
3. Display Operation: Displays all the elements currently in the queue. If the queue is
empty, print "Queue is empty".
4. Exit Operation: Exits the program.
The queue is implemented in a circular fashion, and when the queue is full, further enqueues
are rejected until space is available
Set – 10
Q1. Siri is a computer science student who loves solving mathematical problems. She
recently learned about infix and postfix expressions and was fascinated by how they can be
used to evaluate mathematical [Link] decided to write a program to convert an infix
expression with operators to its postfix form. Help Siri in writing the program.
Q2. Chandra is a cyclist who loves collecting data about her bike rides. She has a collection
of bike ride data in the form of speeds (in km/h) that she wants to store in a hash table.
However, she is concerned about efficiently storing this data using quadratic probing, a
collision resolution technique. Write a program to help Chandra find the fastest bike speed
along with its index in the hash table (table size 10). For each bike, calculate a hash index
using the modulo operation (% tableSize).
Q3. Milton is a diligent clerk at a school who has been assigned the task of managing class
schedules. The school has various sections, and Milton needs to keep track of the class
schedules for each section using a stack-based system. He uses a program that allows him to
push, pop, and display class schedules for each section. Milton's program uses a stack data
structure, and each class schedule is represented as a character. Help him write a program
using a linked list.
Internal Examiner External Examiner