0% found this document useful (0 votes)
27 views

Data Structure_question paper

Uploaded by

pandiridurga21
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views

Data Structure_question paper

Uploaded by

pandiridurga21
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Regulation: R22C22 Course Code: 22TP201/8

II B. Tech I Semester Regular/Supplementary Examinations – December, 2024


DATA STRUCTURES
(BI/BIOTECH/BME/CHEM/CIVIL/CS&BS/CSE/CSE(CS)/CSE(DS)/CSE(AI&ML/
ECE/EEE/FT/IT/MECH/R&A/TT)
Time: 150 Min Max. Marks:60M
SECTION – A
Answer all Four questions 4×8M=32M

1. a) How does binary search differ from linear search? Can binary search be used on a
linked list? Why or why not?
b) Design an algorithm/Pseudocode to print the sequence of 'mid' values while comparing
search elements when using a binary search.
Consider the following sorted list of elements:
index 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14

value 2 4 7 10 13 16 17 20 24 28 31 38 41 43 45
c) Write the sequence of ‘Mid’ values when searching the elements 28 and 16 from the
given list of elements by using the above binary search (b) algorithm.

2. a) What does a stack support the primary operations? How stack is represented using an
array and Linked list?
b) You are given a stack of N integers such that the first element represents the top and
the last represents the bottom. You need to pop at least one element from the stack. At
any one moment, you can convert a stack into a queue. The bottom of the stack represents
the front of the queue. You cannot convert the queue back into a stack. Design an
algorithm/Pseudocode to remove exactly K elements to maximize the sum of the K
removed elements.
c) Find the sum of K removed elements for the given ten integers by using the above (b)
algorithm, where the value of K is five and Integers = {8, 7, 6, 5, 4, 3, 2, 1, 9, 10}

3. a) What are the components of a Node in a Linked List? What are the advantages of a
Linked List over an Array?
b) Design an algorithm/ Pseudocode to check whether the linked list has a loop. Describe
an example with a linked list representation.
c) Design an algorithm or pseudocode to remove the nodes in the linked list that have a
greater value to their right. Trace with the given scenario.
Input: 10 -> 12 -> 15 -> 20 -> 5 -> 16 -> 25 -> 8 -> NULL
Output: 12 -> 17 -> 22 -> NULL

1 of 2
Regulation: R22C22 Course Code: 22TP201/8

4. a) How Queue is represented using an array and Linked list. What is the "First In, First
Out" (FIFO) principle in a queue?
b) You are given an array A of n integers. You have to make a queue and stack of the
given integers. Design an algorithm/Pseudocode that the Queue should contain only
prime numbers and the stack should contain only composite numbers. All the numbers
in the array will be > 1.
Note: The rule to form the stack and queue is that you can generate the array using the
pop and dequeue operations.
c) Let the array A contain five integers {7, 21, 18, 3, 12}, then the content of queue and
stack will be: Queue: 7, 3
Stack: 12, 18, 21
Print the operations (Pop/dequeue) along with the elements in the sequence to generate
the given array from the stack and queue.

SECTION - B
Answer all Two questions 2×14M=28M

5. In Metropolitan City, the public transportation system is represented as a graph with Bus
stations as nodes and Bus routes as edges. You are the transit planner, ensuring passengers
can navigate the metro system efficiently. The graph starts empty, and you need to add
connections between bus stations and perform operations to find optimal bus routes.
a) Design an algorithm/Pseudocode to Add the following metro stations and routes to the
graph:
Bus Stations: A, B, C, D, E
Routes: A -> B, A -> C, B -> D, C -> E, D -> E.
b) Modify the graph by adding route B -> E and re-running BFS to find the new shortest
route from Bus Station A to E.
c) Determine the shortest route from Bus Station A to E by using BFS.
d) Explore all routes from Bus Station A to E and list them using DFS.

6. In a social media application, an AVL Tree manages user IDs to facilitate quick searches
and updates in user interactions. The efficiency of the AVL Tree is critical for providing
a responsive user experience.
a) Insert the following user IDs: 1500, 1200, 1800, 1400, 2000, 1700, 1600. Explain the
AVL Tree structure for each insertion and note any rotations needed for balance.
b) After all insertions, calculate the tree's height and the nodes' average depth. Discuss
how these factors affect user query times.
c) Delete the user IDs 1200 and 1500 and insert a new user ID: 1550. Detail the
necessary rotations and adjustments to maintain AVL properties.
d) Analyse how the choice of an AVL Tree impacts the scalability of this application
compared to a hash table or binary search tree.
e) Design and develop an algorithm for calculating the balance factor for the given
transaction ID.

2 of 2

You might also like