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

Advanced Data Structure and Algorithms Question Bank

The document is a question bank for the course MC4101 - Advanced Data Structures and Algorithms, covering topics such as algorithms, complexity analysis, hierarchical data structures, graphs, and algorithm design. It includes definitions, characteristics, and properties of various data structures and algorithms, as well as questions for different units. The content is structured into parts A, B, and C, with questions ranging from definitions to detailed explanations and examples.

Uploaded by

Prakash Raj
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Advanced Data Structure and Algorithms Question Bank

The document is a question bank for the course MC4101 - Advanced Data Structures and Algorithms, covering topics such as algorithms, complexity analysis, hierarchical data structures, graphs, and algorithm design. It includes definitions, characteristics, and properties of various data structures and algorithms, as well as questions for different units. The content is structured into parts A, B, and C, with questions ranging from definitions to detailed explanations and examples.

Uploaded by

Prakash Raj
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

DEPARTMENT OF MCA

QUESTION BANK

MC4101-ADVANCED DATA STRUCTURES AND


ALGORITHMS

I - MCA
MC4101 - ADVANCED DATA STRUCTURES AND ALGORITHMS
QUESTION BANK

UNIT 1 - ROLE OF ALGORITHMS IN COMPUTING & COMPLEXITY


ANALYSIS

PART - A

1. Define Algorithm
An Algorithm is a set of well-defined instructions designed toper form a
specific set of tasks. Algorithms are used to perform calculations, automatic
reasoning, data processing, computations, and problem-solving.

2. Write the Characteristics of an algorithm


 Unambiguous
 Input
 Output
 Finiteness
 Feasibility
 Independent

3. What is Time Complexity?
The time complexity of an algorithm quantifies the amount of time taken by
an algorithm to run as a function of the length of the input. Note that the time
to run is a function of the length of the input and not the actual execution
time of the machine on which the algorithm is running on.

4. Define Asymptotic Analysis


Asymptotic analysis of an algorithm refers to defining the mathematical
boundation / framing of its run-time performance. Using asymptotic analysis, we can
very well conclude the best case, average case, and worst case scenario of an
algorithm.

5. What are the Asymptotic Notations?


Asymptotic notations to calculate the running time complexity of an
algorithm. Ο Notation, Ω Notation, θ Notation

6. What is the necessity of algorithm analysis?


It provides a systematic way to evaluate the efficiency and performance of
algorithms, ensuring their suitability for solving specific problems under given
constraints.

7. Why we use data structure and algorithms?


Data Search − Consider an inventory of 1 million(106) items of a store. If the
application is to search an item, it has to search an item in 1 million(106) items every time
slowing down the search. As data grows, search will become slower.
Processor speed − Processor speed although being very high, falls limited if the
data grows to billion records.
Multiple requests − As thousands of users can search data simultaneously on a
web server, even the fast server fails while searching the data.

8. Define Recursion
Recursion Tree Method is a pictorial representation of an iteration method
which is in the form of a tree where at each level nodes are expanded.

9. Explain O notation
The theta notation bounds a function from above and below, so it defines
exact asymptotic behavior. A simple way to get the Theta notation of an
expression is to drop low-order terms and ignore leading constants.

10. Name those Properties of Asymptotic Notations


General Properties
Transitive Properties
Reflexive Properties
Symmetric Properties
Transpose Symmetric Properties

PART – B
1. Explain Asymptotic notations and list out common notations with an
example.
2. Explain Recursion Tree Method with an example.
3. Explain about Importance of efficient algorithms.
PART – C
1. Explain following :
i) Algorithm
ii) Time and Space Complexity
iii) Asymptotic Analysis
iv) Asymptotic Notations
UNIT – II HIERARCHICAL DATA STRUCTURE
PART - A
1. Write down the properties of Red Black Trees?
Red Black Trees having three types of properties. These are Rotations,
Insertion, and Deletion.

2. What is heap is used for?


A Binary Heap is a Binary Tree with following properties.

1) It’s a complete tree (All levels are completely filled except possibly the last
level and the last level has all keys as left as possible). This property of Binary
Heap makes them suitable to be stored in an array.

2) A Binary Heap is either Min Heap or Max Heap. In a Min Binary Heap, the key
at root must be minimum among all keys present in Binary Heap. The same
property must be recursively true for all nodes in Binary Tree. Max Binary Heap is
similar to MinHeap.

3. Name that all terminlogies


Names are from Botany and Genealogy: node, branch, depth, height, root,
leaf, non-leaf (inner node), path, forest; parent, child, sibling, cousin,
ancestor, descendant, and subtree.

4. What is Root?
In a tree data structure, It is specially designed data item in a tree. It is the
first in the hierarchical arrange data items. Every tree must have root node. In
any tree, there must be only one root node. We never have multiple root
nodes in a tree.

5. What is Edge?
In a tree data structure, the connecting link between any two nodes is called
as EDGE. In a tree with 'N' number of nodes there will be a maximum of 'N-
1' number of edges

6. Define Parent.
In a tree data structure, the node which is predecessor of any node is called as
PARENT NODE. In simple words, the node which has branch from it to any
other node is called as parent node. Parent node can also be defined as "The
node which has child / children".

7. Define Child
In a tree data structure, the node which is descendant of any node is called as
CHILD Node. In simple words, the node which has a link from its parent
node is called as child node. In a tree, any parent node can have any number
of child nodes. In a tree, all the nodes except root are child nodes.
8. Define Siblings
In a tree data structure, nodes which belong to same Parent are called as
SIBLINGS. In simple words, the nodes with same parent are called as
Sibling nodes.

9. Define Internal Nodes.


In a tree data structure, the node which has atleast one child is called as
INTERNAL Node. In simple words nodes other than leaf nodes are called as
Internal Nodes. The root node is also said to be Internal Node if the tree has
more than one node. Internal nodes are also called as 'Non-Terminal' nodes.

10. Define Binary Tree.


A binary tree is a tree-type non-linear data structure with a maximum of two
children for each parent (i.e., every node has either no child or one child node
or two child nodes). It consists of one specially designated node called
the root of the binary tree, Child node in a binary tree on the left is
termed as 'left child node' and node in the right is termed as the 'right child
node.' The elements of two disjoint binary trees called the left subtree and
right sub tree of the root

11. Properties of Binary Tree


The maximum number of nodes at level ‘l’ of a binary tree is 2l.Level of the
root is 0.For root, l = 0, number of nodes = 20 = 1.
• Maximum number of nodes present in binary tree of height h is 2h−1. Here
height is the max number of nodes on root to leaf path. Here we are
considering height of a tree with one node is 1.
• In a Binary Tree with N nodes, minimum possible height or the minimum
number of levels is? Log2(N+1).If we consider that the height of leaf node is
considered as 0, then the formula will be log2(n+1)−1
• A binary tree with ‘L’ leaves has at least log2L+1 number of levels.
• If a binary tree has 0 or 2 children, then number of leaf nodes are always
one more than nodes with two children.

12. List down the Binary Search Tree Operations


Search, Insertion and Deletion

13. What is B-Tree?


B Tree is a self-balancing data structure based on a specific set of rules for
searching, inserting, and deleting the data in a faster and memory efficient
way. In order to achieve this, the following rules are followed to create a B
Tree.
14. Why we use B-Tree?
 Reduces the number of reads made on the disk
 B Trees can be easily optimized to adjust its size (that is the number
of child nodes) according to the disk size
 It is a specially designed technique for handling a bulky amount of
data.
 It is a useful algorithm for databases and file systems.
 A good choice to opt when it comes to reading and writing large
blocks of data

PART B
1. Explain various cases of deletion in binary search trees with an example for each .
2. Define B-Tree and explain the inserting and deletion operation of B tree with
pseudocode with example.
3. Explain Heap data structure and also explain about min heap and max heap with one
example of heap construction.
4. Explain the following
i) Binary Search Tree
ii) Red Black Trees.
iii) Rotations in BST
iv) Traversal in B-Tree
v) Applications of Heaps.
vi) Operations in Min heap
PART C
1. Explain the Following
i) Disjoint sets
ii) Properties of Intersection
iii) Fibonacci Heaps.
iv) Memory representation of the Nodes in a Fibonacci Heap
v) Operations on a Fibonacci Heap
vi) Bounding the maximum degree
UNIT – III GRAPHS
PART A
.
1. List out the steps in Floyd-Warshall algorithm
Initialize the distance matrix:
Create a matrix dist[][] where dist[i][j] holds the shortest distance
between vertex i and vertex j. Initially, set:
 dist[i][j] = weight of edge (i, j) if there's an edge.
 dist[i][j] = ∞ if no edge exists between i and j (except for diagonal
elements, dist[i][i] = 0).
Update the distance matrix:
For each vertex k, iterate through all pairs of vertices i and j, and
update the matrix as:
dist[i][j]=min⁡(dist[i][j],dist[i][k]+dist[k][j])dist[i][j] = \min(dist[i][j],
dist[i][k] + dist[k][j])dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j])
Repeat this process for every intermediate vertex k.

2. What are the difference ways to represent graphs in memory?


Graphs can be represented in memory using several different methods, each
suited for specific use cases and types of graphs (e.g., sparse or dense graphs).

3. What is Adjacent nodes?


Any two nodes which are connected by an edge in a graph are called adjacent
nodes. For example, if an edge x ε E is associated with a pair of nodes (u,v)
where u, v ε V, then wesay that the edge x connects the nodes u and v.

4. What is Directed graph?


A graph in which every edge is directed is called a directed graph.

5. What is Undirected graph?


A graph in which every edge is undirected is called a directed graph.

6. What is Loop?
An edge of a graph which connects to itself is called a loop or sling.

7. What is Weighted Graph?


A graph in which weights are assigned to every edge is called a weighted
graph.

8. What is Out degree of a graph?


In a directed graph, for any node v, the number of edges which have v as
their initial node is called the out degree of the node v.

9. What is In degree of a graph?


In a directed graph, for any node v, the number of edges which have v as
their terminal node is called the in degree of the node v.
10. Describe Path in a graph
The path in a graph is the route taken to reach terminal node from a starting
node

11. Define Simple path


A path in a diagram in which the edges are distinct is called a simple path. It
is also called as edge simple.

12. Define Cycle on circuit


A path which originates and ends in the same node is called a cycle or circuit.

13. Define Breadth First Search(BFS)


BFS performs simultaneous explorations starting from a common point and
spreading out independently.

14. Define Tree Edge


If w is undiscovered at the time v w is explored, then v w is called a tree edge
and v becomes the parent of w.

15. Define Back Edge


If w is the ancestor of v, then vw is called a back edge.

16. Display Complexity Analysis


 Time complexity: O(V + E), where V is the number of vertices and E is the
number of edges in the graph.
 Space Complexity: O(V). Since an extra visited array is needed of size V.

17. Write about Topological Sort?


A topological sort on a Graph G(V,E) is a arrangement of its nodes so that all
the edges point from left to right. This can be useful in cases where say there is a
ordering of a certain set of events and such events are repressented by a directed
edge from node u to v if u occurs before v.

18. What is Spanning Tree?


Undirected and connected graph , a spanning tree of the graph is a tree that
spans (that is, it includes every vertex of ) and is a subgraph of (every edge in
the tree belongs to ).

19. What is Minimum Spanning Tree?


Minimum spanning tree has direct application in the design of
networks. It is used in algorithms approximating the travelling salesman
problem, multi-terminal minimum cut problem and minimum-cost weighted
perfect matching.
20. Write Short notes on Prim’s Algorithm?
Prim’s Algorithm also use Greedy approach to find the minimum spanning
tree. In Prim’s Algorithm we grow the spanning tree from a starting position. Unlike
an edge in Kruskal's, we add vertex to the growing spanning tree in Prim's.

PART – B
1. List out the steps in Kruskal’s algorithms and apply on the following graph to
construct minimum cost spanning tree. Show the step by step construction of the
tree.

2. Difference between DFS and BFS graph traversal algorithms. Consider a tree of
minimum height of 4, and do BFS and DFS traversals.
3. Write First Depth Algorithm and apply it on the following graph represented as
an adjacency matrix

4. Explain the following :


i) DFS and BFS
ii) Single - Source Shortest Path
iii) Topological Sort
iv) The Floyd –Warshall Algorithm
v) Handling Disconnected Graph
PART –C
1. Apply Dijikstra’s Algorithm on the following graph and show the sortest from
vertex 0 to all other vertices in the graph. Show the content of all the arrays at
each step.

2. Difference between Krushkal and prim’s Algorithms with suitable examples for
each.
3. Breify explain about the Floyd-Warshall Algorithm.
UNIT – IV ALGORITHM DESIGN AND ANALYSIS
1. Describe about Algorithm
The algorithm is defined as a collection of unambiguous instructions
occurring in some specific sequence and such an algorithm should produce output
for given set of input infinite amount of time.

2. What is Greedy Algorithm?


In greedy method, the solution is constructed through a sequence of steps,
each expanding a partially constructed solution obtained so far, until a complete
solution to the problem is reached. At each step the choice made should be,
Feasible – It should satisfy the problem’s constraints. Locally Optimal – Among all
feasible solutions the best choice is to be made. Irrevocable – Once the particular
choice is made then it should not get changed on subsequent steps

3. Why we need Divide and Conquer In?


Divide and conquer method, a given problem is ,i. Divided into smaller sub
problems. ii. These sub problems are solved independently. iii. Combining all the
solutions of sub problems into a solution of the whole.
 If the sub problems are large enough then divide and conquer is
reapplied.
 The generated sub problems are usually of same type as the original
problem.
 A control abstraction for divide and conquer is as given
below using control abstraction a flow of control of a procedure is
given.

4. What is Dynamic Programming?
Dynamic Programming is typically applied to optimization problem. For
each given problem, we may get any number of solutions from which we obtain for
optimum solution (i.e. minimum value or maximum value solution.) And such an
optimal solution becomes the solution to the given problem.

5. Define Backtracking
Backtracking is a method in which the desired solution is expressed as n
tuple (x1,x2, x3….. x n)which is chosen from solution space, using
backtrack formulation. The solution obtained i.e. (x1, x2, x3….. x n)
can either minimizes or maximizes or satisfies the criteria function.

6. Define State Space Tree


A state space tree is a rooted tree whose nodes represent partially constructed
solutions to given problem. In backtracking method the state space tree is built for
finding the solution. This tree is built using depth first search fashion.
7. Define Algorithm Heading
It consists of name of algorithm, problem description, input and output

8. Define Algorithm Body


It consists of logical body of the algorithm by making use of various
programming constructs and assignment statement

9. Explain Big oh notation


Let F(n) and g(n) be two non-negative functions. Let n0 and constant c are
two integers such that n0 denotes some value of inputand n> n0 similarly c is some
constant such that c>0. We can write F(n)<=c*g(n). then F(n) isbig oh of g(n). It is
also denoted as F(n)€O(g(n)). In other words F(n) is less than g(n) ismultiple of
some constant c.

10. What is Recurrence equation?


The recurrence equation is an equation that defines a sequence
recursively. It is normally in following form T(n) = T(n-1)+n …..1for n>0T(0) = 0
…..2Here equation 1 is called recurrence relation and equation 2 is called initial
condition. The recurrence equation can have infinite number of sequence. The
general solution to there cursive function specifies some formula.

11. Difference between P and NP?


Problems that can be solved in polynomial time” (“P” stands for polynomial).
E.g. Searching of key element, sorting of elements, All pair shortest path.NP stands
for “non-deterministic polynomial time”. Note that NP does not stand for “on-
polynomial”
E.g. Traveling salesman Problem, graph coloring problem, Knapsack problem,
Hamiltonian circuit problem.

12. What is Performance Measurement


Performance measurement is concerned with obtaining the space
and the time requirements of a particular algorithm.

13. What is Space Complexity


The space complexity of an algorithm is the amount of memory it needs to
run to completion.

14. What is Time Complexity


The time complexity of an algorithm is the amount of computer time it needs
to run to completion.
15. Differentiate greedy and dynamic programming techniques.
 Greedy Algorithm: Makes the best local choice at each step, hoping it leads to the
global optimum. It is faster but may not always provide an optimal solution for all
problems (e.g., Kruskal's and Dijkstra's algorithm).
 Dynamic Programming (DP): Solves problems by breaking them into overlapping
subproblems and storing the results to avoid recomputation. It guarantees an optimal
solution for problems with optimal substructure (e.g., Fibonacci, Knapsack
problem).

16. Is dynamic programming is better than greedy algorithm design technique
justify?
Dynamic Programming (DP) and Greedy Algorithms are both algorithm
design techniques used to solve optimization problems, but whether one is "better"
than the other depends on the problem and its characteristics.

17. What is the main idea of dynamic programming?


Dynamic programming is basically, recursion plus using common sense.
What it means is that recursion allows you to express the value of a function in terms
of other values of that function. Where the common sense tells you that if you
implement your function in a way that the recursive calls are done in advance, and
stored for easy access, it will make your program faster. This is what we call
Memoization - it is memorizing the results of some specific states, which can then be
later accessed to solve other sub-problems.

18. Define Huffman coding?


Huffman coding is a lossless data compression algorithm. The idea is to assign
variable-length codes to input characters, lengths of the assigned codes are based on the
frequencies of corresponding characters. The most frequent character gets the
smallest code and the least frequent character gets the largest code.

19. Specify the longest common subsequence of the following set.


s1 = {B,C,D,A,A,C,D} , s2 = {A,C,D,B,A,C}
Create a 2D matrix: We initialize a matrix dp of size (n+1)×(m+1)(n+1) \times
(m+1)(n+1)×(m+1), where nnn is the length of s1s_1s1 and mmm is the length of
s2s_2s2. The value at dp[i][j] will store the length of the LCS of the first iii characters
of s1s_1s1 and the first jjj characters of s2s_2s2.
Fill the matrix:
 If s1[i−1]=s2[j−1]s_1[i-1] = s_2[j-1]s1[i−1]=s2[j−1], then
dp[i][j]=dp[i−1][j−1]+1dp[i][j] = dp[i-1][j-1] + 1dp[i][j]=dp[i−1][j−1]+1.
 Otherwise, dp[i][j]=max⁡(dp[i−1][j],dp[i][j−1])dp[i][j] = \max(dp[i-1][j],
dp[i][j-1])dp[i][j]=max(dp[i−1][j],dp[i][j−1]).
Backtrack to find the LCS: Start from dp[n][m] and trace back to dp[0][0] to
construct the LCS.
PART – B

1. Explain with an example of Huffman Coding technique . List few


applications of Huffman Coding.
2. Explain Matrix Chain Multiplication algorithm with an example.
3. Write about Greedy algorithms and Greedy Strategy.

PART - C
1. Explain the following :
I. Elements, Components and Applications of Dynamic
Programming
II. LCS using Greedy Algorithm with example
III. Build Huffman Tree with example
UNIT – V NP COMPLETE AND NP HARD

PART A
1. Draw a diagram showing relationship between P,NP,NP hard and NP Complete
problems in advanced data structure and algorithms?

2. When can we say an algorithm takes polynomial time?

NP complete problems are problems whose status is unknown. No polynomial


time algorithm has yet been discovered for any NP complete problem, nor has
anybody yet been able to prove that no polynomial-time algorithm exists for any of
them. The interesting part is, if any one of the NP complete problems can be solved
in polynomial time, then all of them can be solved.

3. List out NP Hard problems.

The circuit-satisfiability problem


Set Cover
Vertex Cover
Travelling Salesman Problem

4. What is Reduction?
Let L1 and L2 be two decision problems. Suppose algorithm A2
solves L2. That is, if y is an input for L2 then algorithm A2 will answer
Yes or No depending upon whether y belongs to L2 or not. The idea
is to find a transformation from L1 to L2 so that algorithm A2 can be part of
an algorithm A1 to solve L1.
5. How to prove that a given problem is NP Complete?
From the definition of NP-complete, it appears impossible to
prove that a problem L is NP-Complete. By definition, it requires us to
that show every problem in NP in polynomial time reducible to L.
Fortunately, there is an alternate way to prove it. The idea is to take a
known NP-Complete problem and reduce it to L. If polynomial time
reduction is possible, we can prove that L is NP-Complete by
transitivity of reduction (If a NP-Complete problem is reducible to L in
polynomial time, then all problems are reducible to L in polynomial time).

6. What was the first problem proved as NP-Complete?


There must be some first NP-Complete problem proved by definition
of NP-Complete problems. SAT (Boolean satisfiability problem) is
the first NP-Complete problem proved by Cook (See CLRS book for
proof).

7. What is Hamiltonian cycle problem?


Hamiltonian cycle problem is an undirected graph G, does G have a
cycle that visits each vertex exactly once? There is no known polynomial
time algorithm for this dispute. Note: - It means you can't build a
Hamiltonian cycle in a graph with a polynomial time even if there is no
specific path is given for the Hamiltonian cycle with the particular
vertex, yet you can't verify the Hamiltonian cycle within the polynomial
time

8. Describe the classes of NP-hard and NP Complete?


Decision problem/ Decision algorithm: Any problem for which the answer
is either zero or oneis decision problem. Any algorithm for a decision problem is
termed a decision algorithm.
Optimization problem/ Optimization algorithm: Any problem that
involves the identification ofan optimal (either minimum or maximum) value of a
given cost function is known as an optimization problem. An optimization algorithm
is used to solve an optimization problem

9. Write any 4 examples of NP-Complete problems?


 Packing problems: SET-PACKING, INDEPENDENT-SET.
 Covering problems: SET-COVER, VERTEX-COVER.
 Sequencing problems: HAMILTONIAN-CYCLE, TSP.
 Partitioning problems: 3-COLOR, CLIQUE.
 Constraint satisfaction problems: SAT, 3-SAT.
 Numerical problems: SUBSET-SUM, PARTITION, KNAPSACK
10.What is Non-deterministic algorithm?
A non-deterministic algorithm terminates unsuccessfully if and only if there
exists noset of choices leading to a success signal. Whenever, there is a set of
choices that leads toa successful completion, then one such set of choices is
selected and the algorithmterminates successfully

11.What is Polynominal time and Non-Polynominal time?


Polynomial Time algorithms Problems whose solutions times are bounded by
polynomials of small degree are calledpolynomial time algorithmsExample: Linear
search, quick sort, all pairs shortest path etc.
Non- Polynomial time algorithms Problems whose solutions times are bounded
by non-polynomials are called non- polynomial time algorithms
Examples: Travelling salesman problem, 0/1 knapsack problem etcIt is
impossible to develop the algorithms whose time complexity is polynomial for non-
polynomial time problems, because the computing times of non-polynomial are
greater than polynomial. A problem that can be solved in polynomial time in one
model can also be solved in polynomial time.

12.Write about Cook’s theorem

Cook’s Theorem implies that any NP problem is at most polynomially harder than
SAT. This means that if we find a way of solving SAT in polynomial time, we will then
be in a position to solve any NP problem in polynomial time. This would have huge
practical repercussions, since many frequently encountered problems which are so far
believed to be intractable are NP. This special property of SAT is called NP-
completeness. A decision problem is NP-complete if it has the property that any
NP problem can be converted into it in polynomial time

PART B
1. Explain NP-Complete problem with an example.
2. Explain the Relationship between P,NP,NP-hard, NP-Complete.
3. What are the problems in NP and NP-hard?
4. Explain about Cook’s theorem.
PART C
1. Discuss in detail about NP-hard and NP –Complete problems.
2. Difference between NP, NP-hard and NP- Complete problems with suitable
exmaples.
PREVIOUS YEAR QUESTION PAPER:
https://www.binils.com/wp-content/uploads/2024/01/MC-4101-Advanced-Data-Structures-and-
Algorithms.pdf

https://www.studocu.com/in/document/anna-university/master-of-computer-
applications/mca-i-semester-previous-year-question-paper-regulation-2021/56696781

REFERENCE NOTES
https://www.studocu.com/in/document/anna-university/master-of-computer-
applications/mc4101-ads-notes-advance-data-structure-nodes/48728773

You might also like