Introduction to Algorithms
3rd Edition
ISBN: 9780262033848
Author: Thomas H. Cormen, Ronald L. Rivest, Charles E. Leiserson, Clifford Stein
Publisher: MIT Press
expand_more
expand_more
format_list_bulleted
Question
Chapter 16.1, Problem 5E
Program Plan Intro
To modify the Activity-Selection problem in such a way that the total value of activities scheduled is maximized, that is,
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Question 2:
Consider the 0/1 knapsack problem. Given Nobjects where each object is specified by a
weight and a profit, you are to put the objects in a bag of capacity C such that the sum of
weights of the items in the bag does not exceed Cand the profits of the items is maximized.
Note that you cannot use an item type more than once.
a. Using dynamic programming, write an algorithm that finds the maximum total
value according to the above constraints.
b. What is the complexity of your algorithm?
c. Show the dynamic programming table for the following data:
W= { 2 ,7 , 1} , P={ 3 ,15 , 2 } and C=8.
There are n people who want to carpool during m days. On day i, some subset ???? of people want to carpool, and the driver di must be selected from si . Each person j has a limited number of days fj they are willing to drive. Give an algorithm to find a driver assignment di ∈ si each day i such that no person j has to drive more than their limit fj. (The algorithm should output “no” if there is no such assignment.) Hint: Use network flow. For example, for the following input with n = 3 and m = 3, the algorithm could assign Tom to Day 1 and Day 2, and Mark to Day 3.
Person
Day 1
Day 2
Day 3
Driving Limit
1 (Tom)
x
x
x
2
2 (Mark)
x
x
1
3 (Fred)
x
x
0
Develop a dynamic programming algorithm for the knapsack problem: given n items of know weights w1, . . . , wn and values v1, . . . ,vn and a knapsack of capacity W, find the most valuable subset of the items that fit into the knapsack. We assume that all the weights and the knapsack’s capacity are positive integers, while the item values are positive real numbers. (This is the 0-1 knapsack problem).
Analyze the structure of an optimal solution.
Give the recursive solution.
Give a solution to this problem by writing pseudo code procedures.
Analyze the running time for your algorithms.
Chapter 16 Solutions
Introduction to Algorithms
Ch. 16.1 - Prob. 1ECh. 16.1 - Prob. 2ECh. 16.1 - Prob. 3ECh. 16.1 - Prob. 4ECh. 16.1 - Prob. 5ECh. 16.2 - Prob. 1ECh. 16.2 - Prob. 2ECh. 16.2 - Prob. 3ECh. 16.2 - Prob. 4ECh. 16.2 - Prob. 5E
Ch. 16.2 - Prob. 6ECh. 16.2 - Prob. 7ECh. 16.3 - Prob. 1ECh. 16.3 - Prob. 2ECh. 16.3 - Prob. 3ECh. 16.3 - Prob. 4ECh. 16.3 - Prob. 5ECh. 16.3 - Prob. 6ECh. 16.3 - Prob. 7ECh. 16.3 - Prob. 8ECh. 16.3 - Prob. 9ECh. 16.4 - Prob. 1ECh. 16.4 - Prob. 2ECh. 16.4 - Prob. 3ECh. 16.4 - Prob. 4ECh. 16.4 - Prob. 5ECh. 16.5 - Prob. 1ECh. 16.5 - Prob. 2ECh. 16 - Prob. 1PCh. 16 - Prob. 2PCh. 16 - Prob. 3PCh. 16 - Prob. 4PCh. 16 - Prob. 5P
Knowledge Booster
Similar questions
- Classes are scheduled at a school. Once students have submitted their course requests, a computer algorithm can determine the optimal schedule for everyone. The school has concluded that it will take too long to determine the best schedule. Instead, they resort to a less sophisticated method that produces a serviceable if not ideal timetable. Which guiding concept is represented here?arrow_forwardThis assignment uses several heuristic search techniques to find possibly optimal truth assignments for variables in the given Boolean formulas (see the bottom of the assignment). The formulas are in conjunctive normal form (ANDs of ORs). The fitness of an assignment is the number of clauses (ORs) that the assignment satisfies. If there are c clauses, then the highest fitness is bounded by c. However, if the formula is not satisfiable, then you cannot simultaneously make all c clauses true. You will use three of the following seven techniques: DPLL Resolution Genetic algorithms Local search Simulated annealing GSAT WalkSAT You must choose at least one complete algorithm to implement - DPLL or Resolution.arrow_forwardWrite a recurrence that would be used in dynamic programming for thefollowing problem: Given a rod of length n and an array A of prices thatcontain all prices of all the pieces smaller than n. Determine the maximumvalue obtained by cutting up the rod and selling the pieces. Note that youcould sell the rod at its original length without cutting it.arrow_forward
- Machine Learning Problem Perform the optimization problem of finding the minimum of J(x) = (2x-3)2 by: (i) defining theta, J(theta), h(theta) as defined in the Stanford Machine Learning videos in Coursera; (ii) plotting J(theta) vs theta by hand then use a program (iii) determining its minimum using gradient descent approach starting from a random initial value of theta = 5. Perform the search for the minimum using the gradient descent approach by hand calculations, i.e., step 1, step 2, etc. showing your work completelyarrow_forwardCT ser.arrow_forward8. A school is creating class schedules for its students. The students submit their requested courses and then a program will be designed to find the optimal schedule for all students. The school has determined that finding the absolute best schedule cannot be solved in a reasonablo time. Instead they have decided to use a simpler algorithm that produces a good but non-optimal schedule in a more reasonable amount of time. Which principle does this decision best demonstrate? O A Unreasonable algorithms may sometimes also be undecidable O B. Heuristics can be used to solve some problems for which no reasonable algorithm exsts O C. efficiency Two algorithms that solve the same problem must also have the same O B. Approximate solutions are often identical to optimal solutionsarrow_forward
- P is the set of problems that can be solved in polynomial time. More formally, P is the set of decision problems (e.g. given a graph G, does this graph G contain an odd cycle) for which there exists a polynomial-time algorithm to correctly output the answer to that problem. What is NP? Consider these five options. A. NP is the set of problems that cannot be solved in polynomial time. B. NP is the set of problems whose answer can be found in polynomial time. C. NP is the set of problems whose answer cannot be found in polynomial time. D. NP is the set of problems that can be verified in polynomial time. E. NP is the set of problems that cannot be verified in polynomial time. Determine which option is correct. Answer either A, B, C, D, or E.arrow_forwardAppendix A 10-Fold Cross Validation for Parameter Selection Cross Validation is the standard method for evaluation in empirical machine learning. It can also be used for parameter selection if we make sure to use the training set only. To select parameter A of algorithm A(X) over an enumerated range d E [A1,..., A] using dataset D, we do the following: 1. Split the data D into 10 disjoint folds. 2. For each value of A e (A1,..., Ar]: (a) For i = 1 to 10 Train A(A) on all folds but ith fold Test on ith fold and record the error on fold i (b) Compute the average performance of A on the 10 folds. 3. Pick the value of A with the best average performance Now, in the above, D only includes the training data and the parameter A is chosen without the knowledge of the test data. We then re-train on the entire train set D using the chosen A and evaluate the result on the test set.arrow_forwardGradient descent is a widely used optimization algorithm in machine learning and deep learning. It is used to find the minimum value of a differentiable function by iteratively adjusting the parameters of the function in the direction of the steepest decrease of the function's value. In gradient descent, the function is first differentiated to find its gradient, which is a vector of the partial derivatives with respect to each of the parameters. The gradient points in the direction of the steepest increase of the function, so to find the minimum, we need to move in the opposite direction, i.e., in the direction of the negative gradient. The algorithm starts from an initial guess for the parameters and iteratively adjusts the parameters by subtracting a small fraction of the gradient from the current parameters. The fraction is determined by the learning rate, which is a hyperparameter that controls the step size of the update. The algorithm updates the parameters…arrow_forward
- The utility function U(x, y) = x + y can be used to describe perfect substitutes preferences. For perfect substitutes, the demand for good x depends on its own price and on the price of y. If px > Py, the consumer only buys good y. If the px < py the consumer will specialize in good x, the demand will be the income divided by the price of x. If the prices are equal, the consumer is indifferent between buying x or y. Given this information: 1. Write a Python function which returns the demands of goods x, and y. The function should accommodate the income level, and the prices. 2. Plot the inverse demand curve for good x. Assume, py = 20, I = 100, and px is between 5 and 30.arrow_forwardimplement Bresenham line drawing algorithm:For Slope |m|<1:Either value of x is increasedOR both x and y is increased using decision parameter.arrow_forwardplease try to simulate the probability of rolling a Die with Sample Space* S={1,2,3,4,5,6} and the probability of each sample point has a 1/6 chance of occurring, i.e., you need to verify that your simulation converges to 1/6 when you select one point of sample space. When X is a random variable for sample point of rolling a Die, Pr(X<=4)=2/3. Please verify this result by simulation. Please let me know how to make an Excel file as stated above.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Operations Research : Applications and AlgorithmsComputer ScienceISBN:9780534380588Author:Wayne L. WinstonPublisher:Brooks Cole
Operations Research : Applications and Algorithms
Computer Science
ISBN:9780534380588
Author:Wayne L. Winston
Publisher:Brooks Cole