Daaproject

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

JAYPEE UNIVERSITY OF INFORMATION TECHNOLOGY

Optimizing Blueberries: Dynamic Programming Approach

Course Name: DESGING


DESIGN AND ANALYSIS
OF ALGORITHMS LAB

SUBMITTED BY: SUBMITTED TO:

Shaurya rana-221030215 Dr. Amit Kumar

Gaurav thakur-221030056
Batch: CS42
Contents
● Introduction
● Problem Statement
● Aims and Objectives
● Significance of the Project
● Project Features
● Code
● Conclusion
INTRODUCTION
Teresa wants to pick up the blueberries in such a way that she
may not exceed the limit proposed.When picking the
blueberries, she noticed that if she pick from the bush i, she
couldn’t pick the blueberries at the bush i+1 (some sort of magic
in rainbowland).Worried about this, Teresa wants to know the
maximum blueberries she can pick, given the number of bushes
and the number of blueberries in each bush.Will contain an
integer T, then, T cases will follow, each case starts with a
number N and K, being N the number of bushes and K the
number of blueberries Teresa will pick as maximum, the next
line contains N integers, each one representing the blueberries
there is on the i-th bush

The project focuses on optimizing the collection of


blueberries in Rainbowland by developing a dynamic
programming solution. The goal is to help Teresa collect
the maximum number of blueberries from a set of
bushes while adhering to a limit on the total number of
blueberries and avoiding picking from adjacent bushes.
PROBLEM STATEMENT:
The major problem the project targets here is :

The main problem addressed in this project is to


determine the optimal strategy for Teresa to collect
blueberries from N bushes in Rainbowland, with a
constraint on the maximum number of blueberries
that can be collected (K) and the restriction of not
picking from adjacent bushes consecutively.

This problem is quite similar to 0/1 knapsack


problem with additional constraints of not being able
to pick adjacent bushes. We will create a matrix dp[]
[], where dp[i] [j]=maximum blueberries that can be
collected from first i bushes with limit being j. We will
fill this matrix row wise in a bottom up manner and
ultimately report the answer.
AIM AND OBJECTIVE:
Aim:
The aim of this project is to develop and implement a dynamic
programming algorithm that efficiently calculates the maximum
number of blueberries Teresa can collect from a set of bushes
in Rainbowland. By addressing the constraints of a limited total
number of blueberries that can be picked (K) and the
prohibition of picking from adjacent bushes consecutively, the
project aims to provide Teresa with an optimal strategy for
blueberry collection.

Objectives:

1. Algorithm Development: Design a dynamic


programming algorithm that effectively solves the
blueberry collection problem by considering the
constraints of the problem statement.
2. Efficient Computation: Implement the algorithm to
ensure efficient computation of the maximum number
of blueberries that can be collected within the
specified limits, enhancing the overall performance of
the solution.
3. Optimal Strategy: Determine and present an optimal
strategy for Teresa to pick blueberries from the
bushes, considering the constraints of the problem to
maximize the total blueberries collected.
4. User-Friendly Interface: Develop a user-friendly
interface that allows easy input of the number of
bushes, blueberries in each bush, and the blueberry
collection limit, enabling users to interact with the
solution seamlessly
SIGNIFICANCE OF THE PROJECT:
This project holds significant importance in the context of
algorithmic problem-solving and practical application in a
fun and engaging scenario like blueberry collection in
Rainbowland. By addressing the optimization challenge of
maximizing blueberry collection while adhering to specific
constraints, the project offers several notable benefits and
contributions:
Importance:
1. Algorithmic Skill Development: The project serves as a
platform for enhancing algorithmic thinking and
problem-solving skills by tackling a real-world
combinatorial problem in a structured and systematic
manner.
2. Decision-Making Enhancement: By providing Teresa
with an optimal strategy for blueberry collection, the
project aids in improving decision-making abilities in
scenarios with constraints and limitations.
PROJECT FEATURE:
1. Dynamic Programming Solution: The project offers a
dynamic programming algorithm that efficiently calculates
the maximum number of blueberries Teresa can collect,
considering constraints such as the total number of
blueberries that can be picked and the adjacency
prohibition.
2. Interactive Interface: Users can interact with the solution
through an intuitive and user-friendly interface that allows
for easy input of parameters such as the number of bushes,
blueberries in each bush, and the blueberry collection limit.
3. Efficient Computation: The algorithm is implemented to
ensure swift and accurate computation of the optimal
blueberry collection strategy, providing users with timely
results and insights.
4. Backtracking Mechanism: By incorporating a backtracking
mechanism, the project enables users to trace the selected
bushes that contribute to the maximum blueberries
collected, enhancing transparency and understanding of
the solution.
5. User Input Validation: The project includes input validation
mechanisms to ensure that user-provided data, such
faults and as the
page
number of bushes and blueberries, meets the specified
requirements, enhancing the robustness and reliability of
the solution.
6. Menu-Driven Navigation: A menu-driven interface guides
users through the project, offering options to run new test
cases, view results, and exit the program, facilitating
seamless navigation and interaction.
7. Memory Management: The project incorporates memory
management techniques to optimize resource utilization
and prevent memory leaks, ensuring efficient performance
and stability of the solution.
CODE:
OUTPUT:
Case 1: Run a
new test case

Case 2: Exit
CONCLUSION:

In conclusion, the project successfully


implements a dynamic programming solution to
the blueberry collection problem in
Rainbowland. By calculating the maximum
number of blueberries that can be collected
within the specified constraints, Teresa can now
strategize her blueberry picking to achieve
optimal results. The project not only provides a
solution to the problem but also enhances
algorithmic thinking and problem-solving skills.

You might also like