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

Solved_DS_A_2024_Sem4 (1)

The document is a solved question paper for a Data Structures and Algorithms exam for B.E. Artificial Intelligence and Data Science, covering various topics such as graphs, trees, algorithms, and file organization. It includes definitions, pseudo code, algorithms like Dijkstra's and Prim's, and examples of data structures like AVL and B+ trees. The paper also discusses indexing, advantages of different data structures, and methods for record representation.

Uploaded by

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

Solved_DS_A_2024_Sem4 (1)

The document is a solved question paper for a Data Structures and Algorithms exam for B.E. Artificial Intelligence and Data Science, covering various topics such as graphs, trees, algorithms, and file organization. It includes definitions, pseudo code, algorithms like Dijkstra's and Prim's, and examples of data structures like AVL and B+ trees. The paper also discusses indexing, advantages of different data structures, and methods for record representation.

Uploaded by

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

Solved Question Paper: Data Structures and Algorithms

Program: B.E. Artificial Intelligence and Data Science


Semester: IV (2019 Pattern)
Exam: May 2024

1. Q1 a) Elaborate following terminologies:


i) Graph
ii) Adjacency List
iii) Adjacency Matrix

i) Graph: A graph is a non-linear data structure consisting of vertices (nodes) and edges
(connections). It can be directed or undirected, weighted or unweighted.
ii) Adjacency List: Represents a graph as a list where each vertex has a list of adjacent
vertices. Efficient for sparse graphs.
iii) Adjacency Matrix: A 2D array where cell (i, j) holds value 1 (or weight) if there's an edge
from vertex i to j.

2. Q1 b) Differentiate between tree and graph.

Tree:
- Hierarchical structure
- No cycles
- Always connected
- One parent per node (except root)
- Edge count = n-1

Graph:
- Network structure
- May have cycles
- May not be connected
- No parent-child restriction
- Any number of edges

3. Q1 c) Write pseudo code for Floyd-Warshall algorithm.

FloydWarshall(dist[][]):
for k = 0 to V-1:
for i = 0 to V-1:
for j = 0 to V-1:
if dist[i][j] > dist[i][k] + dist[k][j]:
dist[i][j] = dist[i][k] + dist[k][j]
4. Q2 a) Find the shortest path using Dijkstra’s algorithm.

Steps:
1. Mark all nodes unvisited. Set distance of source = 0, others = ∞.
2. Set current node = source.
3. Update distances to neighbors.
4. Mark current node as visited.
5. Choose unvisited node with smallest distance.
6. Repeat until all nodes visited.

5. Q2 b) Write Prim’s algorithm to find minimum spanning tree.

Prim(G):
- Initialize all keys = ∞, parent[] = NIL
- Start from any vertex, set its key = 0
- For V vertices:
- Pick u with min key and not in MST
- Include u in MST
- Update key and parent for adjacent vertices

6. Q2 c) Write the applications of:


i) Graph
ii) BFS
iii) DFS

i) Graph: Google Maps, social networks, web crawling.


ii) BFS: Shortest path in unweighted graphs, peer-to-peer networks.
iii) DFS: Topological sort, puzzle solving, cycle detection.

7. Q3 a) Explain following terms w.r.t. symbol table:


i) Insert & lookup operations
ii) Advantages
iii) Disadvantages

Insert: Add identifier and attributes.


Lookup: Retrieve attributes of identifier.
Advantages: Fast access.
Disadvantages: Collision handling, memory usage.

8. Q3 b) Construct an AVL tree: H, I, J, B, A, E, C, F, D, G

AVL Tree (balanced):


E
/ \
B H
/\ \
A C I
\ \
D J
\
F
\
G

9. Q3 c) Insert 15, 10, 17, 7 in splay tree.

Splayed tree after all insertions:


7
\
10
\
15
\
17

10. Q4 a) What is the need of AA tree? List the five invariants that AA tree must satisfy.

AA tree is a balanced binary search tree that simplifies the balancing logic of Red-Black
trees.
Invariants:
1. Left child level is one less than parent.
2. Right child's level equals parent or one less.
3. No two consecutive right links on the same level.
4. Leaf nodes have level 1.
5. Every node has level ≥ 1.

11. Q4 b) K-D Tree Insertion

Used for multi-dimensional data (e.g., 2D points).


Insertion alternates between x and y axes.
Inserted: (7,8), (12,3), (14,1), (4,12), (9,1), (2,7), (10,19).

12. Q4 c) Show balanced AVL tree after deletion

After deleting nodes (30, 55, 60), rebalance tree using rotations as needed to maintain AVL
properties.

13. Q5 a) What is indexing? Advantages? Clustering index?

Indexing improves search performance.


Advantages: Faster queries.
Clustering index: Data stored in sorted order based on key.
14. Q5 b) Construct B-Tree of order 3

Insert data with max 2 keys per node before split.


Final tree balanced with keys sorted across nodes.

15. Q5 c) Why B+ Tree? Properties and advantages.

B+ Tree is better for range queries.


Properties: All data in leaf nodes, internal nodes have keys only.
Advantages: Faster search, better disk utilization.

16. Q6 a) Explain trie tree with example.

Trie stores strings character by character.


Example: 'cat', 'cap', 'car'.
Advantages: Efficient prefix searching.

17. Q6 b) Build B+ tree of order 3

Insert: F, S, Q, K, C, L, H, T, V, W, M, R.
Split nodes when overflow occurs. All data in leaves.

18. Q6 c) Difference between B and B+ tree.

B Tree: Data in internal and leaf nodes.


B+ Tree: Data only in leaves, internal nodes guide search.
B+ supports range queries efficiently.

19. Q7 a) Indexed Sequential File Organization

Combines indexing with sequential files.


Advantages: Fast search, sequential access.
Disadvantages: Complex update and delete.

20. Q7 b) Two ways to represent records

1. Fixed-length: All fields same size.


2. Variable-length: Fields of different sizes, need delimiters or pointers.

21. Q7 c) Indexed sequential vs direct access

Indexed sequential: Uses index + sequence.


Direct access: Uses hashing for immediate access.

22. Q8 a) Sequential File Organization


Records stored one after another.
Advantages: Simple, good for batch processing.
Disadvantages: Slow access, hard to update.

23. Q8 b) What is coral rings? Describe inverted files.

Coral rings: Likely a typo or specific to some curriculum.


Inverted files: Index that maps keywords to document locations.

24. Q8 c) Direct Access File

Uses hash functions to access records directly.


Efficient for large databases requiring fast lookups.

You might also like