CB402 - Daa
CB402 - Daa
in
Program: B.Tech
______________________________________________________
QUE 1- What is an algorithm?(Answer)
Summary - An algorithm is a step-by-step procedure used to solve a problem or
perform a task. It's a precise set of instructions that can be executed by a computer or a
person to achieve a desired outcome.
rgpvprep.in
method involves guessing a bound and then proving it by induction.
______________________________________________________
Summary - Branch and Bound algorithms systematically search through a problem's
solution space, using a bounding function to prune branches.
Greedy algorithms, on the other hand, make locally optimal choices at each step,
aiming to reach a global optimum. Branch and Bound is more exhaustive but
guarantees an optimal solution, while Greedy algorithms are simpler but may not always
find the best solution.
rgpvprep.in
Summary - Here's a BFS algorithm for graph connectivity:
BFS(graph, start)
queue = [start]
visited = set()
while queue is not empty
node = queue.dequeue()
if node not in visited
visit(node)
visited.add(node)
for neighbor in graph.neighbors(node)
queue.enqueue(neighbor)
______________________________________________________
Summary - NP-Complete problems are a subset of NP problems that are at least as
hard as the hardest problems in NP. They have the property that if any NP-Complete
problem can be solved in polynomial time, then all NP problems can also be solved in
polynomial time.
rgpvprep.in
using a divide-and-conquer approach.
Merge(left, right)
result = []
______________________________________________________
while left is not empty and right is not empty
if first element of left <= first element of right
append first element of left to result
remove first element from left
else
append first element of right to result
remove first element from right
append remaining elements of left and right to result
return result
rgpvprep.in
results in a table. It starts with the source node having a distance of 0 and updates the
shortest distances to all other nodes iteratively. At each step, it considers the shortest
path from the source to a node through previously visited nodes. The final table
contains the shortest path distances from the source to all nodes in the graph.
QUE 20- Apply Floyd's algorithm for finding all pairs of shortest paths.(Answer)
Summary - Floyd's algorithm finds all pairs of shortest paths in a weighted graph by
iteratively updating the shortest path distances between every pair of vertices. It starts
with initial distances and gradually improves them until no further improvements can be
made, ensuring that the resulting table contains the shortest paths between all pairs of
vertices.
QUE 22- Apply the substitution method for finding the upper bound.(Answer)
______________________________________________________
Summary - The substitution method for finding the upper bound involves guessing a
solution and then proving it correct. It's often used in recurrence relations, where an
initial guess for the upper bound is refined and verified through mathematical induction
or other proof techniques.
QUE 28- Trace the process for finding max and min elements in a
dataset.(Answer)
Summary - The process of finding the max and min elements in a dataset involves
comparing elements pairwise and updating the maximum and minimum as necessary.
______________________________________________________
This process continues until all elements are compared, resulting in the identification of
the maximum and minimum values.
QUE 29- Explain worst-case complexity for finding max and min
elements.(Answer)
Summary - The worst-case complexity for finding max and min elements is 𝑂 ( 𝑛 ) O(n),
where 𝑛 n is the number of elements in the dataset. This occurs when the maximum or
minimum element is located at the end of the dataset, requiring comparisons with all
other elements.
rgpvprep.in
form the solution to the original problem.
______________________________________________________
QUE 35- Differentiate between best-case, worst-case, and average-case
complexities.(Answer)
Summary -
● Best-case complexity is the minimum time or space required by an algorithm
when given the most favorable input.
● Worst-case complexity is the maximum time or space required when given the
least favorable input.
● Average-case complexity is the expected time or space required over all possible
inputs, often based on probability distributions.
QUE 39- Explain the Master Theorem for analyzing algorithm complexity.(Answer)
Summary - The Master Theorem is a mathematical tool for analyzing the time
complexity of divide-and-conquer algorithms. It provides a formulaic approach to
determine the time complexity of algorithms that follow specific recursive patterns, such
as those found in merge sort, quicksort, and certain tree traversal algorithms.
______________________________________________________
QUE 41- Explain the concept of Memorization in dynamic programming.(Answer)
Summary - Memorization in dynamic programming refers to storing computed solutions
to subproblems in a table or array for future reference. This technique avoids
recalculating solutions for previously solved subproblems, reducing the overall
computational complexity of the algorithm.
rgpvprep.in
Summary - Breadth-First Search (BFS) is a graph traversal algorithm that explores
vertices level by level, starting from a selected vertex. It systematically visits all
neighboring vertices of the current vertex before moving to deeper levels, ensuring the
shortest path to each reachable vertex is discovered.
______________________________________________________
minimum connected structure of a graph, essential for network design, optimization, and
analysis.
rgpvprep.in
______________________________________________________