Seminar Report Format[1] Shreyas666 Copy
Seminar Report Format[1] Shreyas666 Copy
Jnana Sangama,Belagavi-590018
Seminar Report on
“Analysis & Design of Algorithms (BCS401)”
submitted in the partial fulfillment of the requirement for the award degree of
BACHELOR OF ENGINEERING
in
COMPUTER SCIENCE & ENGINEERING
submitted by
SHREYAS E
1AR23CS097
AIEMS
BENGALURU
B. V. V. Sangha’s
AMRUTA INSTITUTE OF ENGINEERING & MANAGEMENT SCIENCES
Bidadi Industrial Area, Bidadi, Bengaluru–562109
TABLE OF CONTENTS
SL Title Page No
.No
1 Introduction to Algorithms 3-4
2 Analysis of Algorithms (Time and Space 5-8
Complexity)
3 Advantages of Algorithms Analysis 9 - 10
4 Topic: Branch and Bound (knapsack problem) 11 - 12
i).Introduction:
ii). Branch and Bound (knapsack problem) Algorithm 13
code
iii).Time complexity of Branch and Bound (knapsack 14 - 15
problem)
iv).Applications of Branch and Bound (knapsack
problem) in real time
ii
Analysis & Design of Algorithms (BCS401) 2024-25
1. INTRODUCTION TO ALGORITHMS
Types of Algorithms
Algorithms can be classified into several types based on their purpose and
strategy:
1.Sorting Algorithms: Such as Bubble Sort, Merge Sort, and Quick Sort.
These are used to arrange data in a specific order.
2.Searching Algorithms: Like Linear Search and Binary Search, used to
locate a particular element within a dataset.
3.Recursive Algorithms: These solve problems by calling themselves
with smaller inputs, such as the Tower of Hanoi or Factorial calculation.
4.Dynamic Programming Algorithms: These store results of
subproblems to avoid repeated work, for example, in the Fibonacci series.
5.Greedy Algorithms: These make the best possible decision at each
step, often used in optimization problems.
Applications of Algorithms
2. ANALYSIS OF ALGORITHMS
1. Time Complexity
3 . ANALYSIS OF ALGORITHMS
2. Space Complexity
Space Complexity measures the total amount of memory an algorithm uses
relative to the input size, including:
Input space
Auxiliary (temporary) space
Like time complexity, space complexity is also expressed using Big O notation.
🔹 Searching Algorithms
🔹 Dynamic Programming
🔹 Graph Algorithms
Prim’s / Kruskal’s O(V + E) Space for edge list, sets, or priority queues
1. Performance Prediction
Analyzing algorithms helps predict their performance in terms of:
Time Complexity (execution time)
Space Complexity (memory usage)
This prediction helps select the most efficient algorithm for a given task,
especially when handling large datasets.
3. Scalability Assessment
Algorithm analysis shows how an algorithm behaves as the input size increases.
This helps determine whether an algorithm can handle real-world, large-scale
problems efficiently.
6. Cost Reduction
Efficient algorithms reduce:
Processing time
Energy consumption
Cloud/server costs for large systems
This is particularly important in commercial or large-scale software systems.
i).Introduction:
The Knapsack Problem is one of the most fundamental problems in
combinatorial optimization. It involves selecting a subset of items with given
weights and profits such that the total profit is maximized without exceeding a
specified weight capacity. The 0/1 Knapsack Problem, in particular, restricts
the selection of items to either completely include or exclude them—fractional
inclusion is not allowed.
Solving the 0/1 Knapsack Problem becomes computationally intensive as the
number of items increases because the total number of possible item
combinations grows exponentially. While brute-force methods can solve it by
evaluating all possible combinations, they are inefficient and impractical for
large inputs.
To address this challenge, the Branch and Bound technique is used. It is a
search-based optimization method that divides the problem into smaller
subproblems (branching) and uses a bound function to estimate the best
possible solution from a given state. If the estimated bound is worse than the
current best known solution, the branch is pruned, meaning it is not explored
further.
Input:
List of n items, each with weight w[i] and profit p[i]
Knapsack capacity W
Output:
Maximum total profit achievable without exceeding capacity W
Steps:
1. Sort items by profit-to-weight ratio in descending order.
2. Initialize:
o Create a root node representing no items taken yet (level = -1, profit
= 0, weight = 0).
o Calculate the upper bound (maximum possible profit) for the root node
using a greedy method (fractional knapsack).
In the worst case, the algorithm may explore all subsets of the items.
Since there are 2^n subsets for n items, the worst-case time complexity is
O(2^n).
Branch and Bound often performs much better than brute force due to
pruning.
The efficiency depends heavily on the quality of the bound function and
the order of item processing.
Summary
Average case Much better than brute force, depends on pruning effectiveness
1. Resource Allocation
Selecting the most profitable combination of resources (items) subject to
capacity constraints, such as budget limits or storage capacity.
Problem Context
A company has a limited budget of ₹100,000 to allocate among several potential
projects or investments. Each project requires a certain investment amount (cost)
and yields an expected profit. The goal is to select a subset of projects to maximize
total profit without exceeding the budget.
Given
Project Cost (Weight) Profit (Value) Profit/Cost Ratio
A 20,000 30,000 1.5
B 50,000 80,000 1.6
C 30,000 50,000 1.67
D 40,000 55,000 1.375
E 10,000 15,000 1.5
5. Continue exploring nodes, updating max profit and pruning as you go.