Garantie de satisfaction à 100% Disponible immédiatement après paiement En ligne et en PDF Tu n'es attaché à rien 4.2 TrustPilot
logo-home
Examen

alg quiz questions and answers

Note
-
Vendu
-
Pages
4
Grade
A+
Publié le
23-02-2024
Écrit en
2023/2024

Consider the following generalization of the Activity Selection Problem: You are given a set of n activities each with a start time si, a finish time fi, and a weight wi. Design a dynamic programming algorithm to find the weight of a set of non-conflicting activities with maximum weight. - ANSWER-Formula: (Sort by finish time) A[i] = max (from activity 1 to i) { A[i - 1] max{A[x]} + wi } (x being activity whose finish time <= activity i's start time) A contiguous subsequence of a list S is a subsequence made up of consecutive elements of S. For instance, if S = {5, 15, −30, 10, −5, 40, 10} then {15, −30, 10} is a contiguous subsequence but {5, 15, 40} is not. Give a dynamic programming algorithm for the following task: You are given a list of numbers, {a1, a2, . . . , an}. You should return the contiguous subsequence of maximum sum (a subsequence of length zero has sum zero). For the preceding example, the answer would be 10, −5, 40, 10, with a sum of 55. - ANSWER-Formula: CSH[i] = max{ 0 CSH[i - 1] + Vi } You are going on a long trip. You start on the road at mile post 0. Along the way there are n hotels, at mile posts a1 < a2 < · · · < an, where each ai is measured from the starting point. The only places you are allowed to stop are at these hotels, but you can choose which of the hotels you stop at. You must stop at the final hotel (at distance an), which is your destination. You would ideally like to travel 300 miles a day, but this may not be possible (depending on the spacing of the hotels). If you travel x miles during a day, the penalty for that day is (300 − x)^2. You want to plan your trip so as to minimize the total penalty-that is, the sum, over all travel days, of the daily penalties. Give a dynamic programming algorithm to determine the optimal sequence of hotels at which to stop. - ANSWER-Formula: P[i] = min (0 <=

Montrer plus Lire moins
Établissement
Alg Quz
Cours
Alg quz








Oups ! Impossible de charger votre document. Réessayez ou contactez le support.

École, étude et sujet

Établissement
Alg quz
Cours
Alg quz

Infos sur le Document

Publié le
23 février 2024
Nombre de pages
4
Écrit en
2023/2024
Type
Examen
Contient
Questions et réponses

Sujets

Aperçu du contenu

alg
quiz
Consider
the
following
generalization
of
the
Activity
Selection
Problem:
You
are
given
a
set
of
n
activities
each
with
a
start
time
si,
a
finish
time
fi,
and
a
weight
wi.
Design
a
dynamic
programming
algorithm
to
find
the
weight
of
a
set
of
non-conflicting
activities
with
maximum
weight.
-
ANSWER-Formula:
(Sort
by
finish
time)
A[i]
=
max
(from
activity
1
to
i)
{
A[i
-
1]
max{A[x]}
+
wi
}
(x
being
activity
whose
finish
time
<=
activity
i's
start
time)
A
contiguous
subsequence
of
a
list
S
is
a
subsequence
made
up
of
consecutive
elements
of
S.
For
instance,
if
S
=
{5,
15,
−30,
10,
−5,
40,
10}
then
{15,
−30,
10}
is
a
contiguous
subsequence
but
{5,
15,
40}
is
not.
Give
a
dynamic
programming
algorithm
for
the
following
task:
You
are
given
a
list
of
numbers,
{a1,
a2,
.
.
.
,
an}.
You
should
return
the
contiguous
subsequence
of
maximum
sum
(a
subsequence
of
length
zero
has
sum
zero).
For
the
preceding
example,
the
answer
would
be
10,
−5,
40,
10,
with
a
sum
of
55.
-
ANSWER-Formula:
CSH[i]
=
max{
0
CSH[i
-
1]
+
Vi
}
You
are
going
on
a
long
trip.
You
start
on
the
road
at
mile
post
0.
Along
the
way
there
are
n
hotels,
at
mile
posts
a1
<
a2
<
·
·
·
<
an,
where
each
ai
is
measured
from
the
starting
point.
The
only
places
you
are
allowed
to
stop
are
at
these
hotels,
but
you
can
choose
which
of
the
hotels
you
stop
at.
You
must
stop
at
the
final
hotel
(at
distance
an),
which
is
your
destination.
You
would
ideally
like
to
travel
300
miles
a
day,
but
this
may
not
be
possible
(depending
on
the
spacing
of
the
hotels).
If
you
travel
x
miles
during
a
day,
the
penalty
for
that
day
is
(300

x)^2.
You
want
to
plan
your
trip
so
as
to
minimize
the
total
penalty-that
is,
the
sum,
over
all
travel
days,
of
the
daily
penalties.
Give
a
dynamic
programming
algorithm
to
determine
the
optimal
sequence
of
hotels
at
which
to
stop.
-
ANSWER-Formula:
P[i]
=
min
(0
<=
k
<=
i)
{
€6,99
Accéder à l'intégralité du document:

Garantie de satisfaction à 100%
Disponible immédiatement après paiement
En ligne et en PDF
Tu n'es attaché à rien


Document également disponible en groupe

Faites connaissance avec le vendeur

Seller avatar
Les scores de réputation sont basés sur le nombre de documents qu'un vendeur a vendus contre paiement ainsi que sur les avis qu'il a reçu pour ces documents. Il y a trois niveaux: Bronze, Argent et Or. Plus la réputation est bonne, plus vous pouvez faire confiance sur la qualité du travail des vendeurs.
AnswersCOM Chamberlain School Of Nursing
S'abonner Vous devez être connecté afin de suivre les étudiants ou les cours
Vendu
1171
Membre depuis
2 année
Nombre de followers
352
Documents
26304
Dernière vente
14 heures de cela
Academic Guru

In my profile, you'll find a range of study resources, including detailed lecture notes, comprehensive summaries, and challenging practice exams. These materials are designed to help you grasp key concepts, review efficiently, and perform your best during assessments.I'm here not just to share but also to learn. Feel free to connect, ask questions, and share your insights. Together, we can make the learning journey more enriching. Browse through my materials, and I hope you find them beneficial for your academic success. Happy studying!

Lire la suite Lire moins
3,6

219 revues

5
97
4
23
3
45
2
15
1
39

Récemment consulté par vous

Pourquoi les étudiants choisissent Stuvia

Créé par d'autres étudiants, vérifié par les avis

Une qualité sur laquelle compter : rédigé par des étudiants qui ont réussi et évalué par d'autres qui ont utilisé ce document.

Le document ne convient pas ? Choisis un autre document

Aucun souci ! Tu peux sélectionner directement un autre document qui correspond mieux à ce que tu cherches.

Paye comme tu veux, apprends aussitôt

Aucun abonnement, aucun engagement. Paye selon tes habitudes par carte de crédit et télécharge ton document PDF instantanément.

Student with book image

“Acheté, téléchargé et réussi. C'est aussi simple que ça.”

Alisha Student

Foire aux questions