WA3
.pdf
keyboard_arrow_up
School
University at Buffalo *
*We aren’t endorsed by this school
Course
411
Subject
Computer Science
Date
Jan 9, 2024
Type
Pages
4
Uploaded by ProfComputerJellyfish103
ConanSam
CSE
331
WHN
Problem
I
The goal is to show that the output set has the highest profit margin
Let A be the output set of the greedy algorithm and O be an optimal solution
Let (I1 ... Ik) be the list of clients in A
Let (J1 ... Jm) be the list of clients in O
Since O is an optimal solution, the profit margin has to be the highest
And since the greedy algorithm selects the client with the highest profit margin for each iteration
Therefore the resulting list has to have the highest profit margin for the given potential client list
Which shows that selecting the client with the highest profit margin is an optimal greedy choice
Problem
2
XY
2
x
exe
2
tht
yet
The reason why the algorithm is correct is because x to the y can also mean that we multiply x y times, since the algorithm splits the bits in half, we have to combine the lower half and the upper half at the end to get the correct result.
Similar to the recursive multiplication algorithm, the recursive power algorithm splits the input y to upper bits and lower bits, once it reaches the stopping condition where the bits cannot be split anymore, the upper bit(s) get multiplied by n times, then the result is multiplied by the lower bit(s).
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
Related Questions
8. 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 solutions
arrow_forward
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.
arrow_forward
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.
arrow_forward
knapsack problem:
given the first table: c beeing value and w beeing weight, W max weight. I got table 2 as a solution to:
2 Solve the Knapsack problem with dynamic programming. To do this, enter the numbers Opt[k,V ] for k = 1,...,5 and V = 1,...,9 in a table. Here Opt[k, V ] is the partial solution obtained for the first k items with maximum weight V. "
Can somebody explain me the values of the table? How do they get calculated?
Also how do i solve the followup-task:
Using the values in the table, determine a solution OPTSOL(I)=(β1,β2,β3,β4), starting with β4. (Use backtracing to do this)
arrow_forward
esc
A
Question 14 of 20:
Select the best answer for the question.
14. Use Gauss-Jordan elimination to solve the following linear system:
-3x + 4y = -6
5x - y = 10
O A. (2,0)
O B. (2,-5)
OC. (-6,2)
OD. (2,2)
O Mark for review (Will be highlighted on the review page)
>
2 T
W
S
#3
E
D
لم
G
$
4 {
R
C
19
F
%
50
F
ف
G
Oll
O
O
U
*00
C
8 A
arrow_forward
(b) One example of a greedy algorithm is the Dijkstra algorithm for finding the
lowest cost path through a weighted graph. The diagram below shows two
weighted graphs that a student wants to investigate using Dijkstra's algorithm.
In each case the task it to find the lowest cost of reaching every node from v₁.
Each graph has a single negative weight in it.
●
V₁
●
10
●
12
V₂
V3
10
V4
V₁
15
Graph (a)
Graph (b)
One of the graphs will yield a correct analysis of the lowest cost for all
vertices, and the other will produce an incorrect analysis. Which of the two
graphs will produce the incorrect analysis, and explain why the greedy nature
of Dijkstra's algorithm is responsible for the incorrect analysis. Your answer
should include the key concept of an invariant.
V₂
(c) The priority queue is a widely used data structure. Priority queues may be
implemented using binary heaps and simple linear arrays. For the basic
priority queue operations of:
30
Building an initial queue
Taking the highest…
arrow_forward
Maximum weight = 20The above problem is a 0/1 Knapsack problem. Here there are 7 different objects labelled from A to G. The objective of this problem is to carry the different objects in your bag in such a way such that the profit is maximized. But you have to make sure that your bag does not exceed the maximum weight i.e. the maximum weight that this bag can carry is less than or equal to 15. Remember you can carry an object exactly once. Now it is your job to use Genetic Algorithm to solve this problem.
1. Encode the problem and create an initial population of 4 different chromosomes
2. Think of an appropriate fitness function to this problem and give proper justification.
3. Use the fitness function to calculate the fitness level of all the chromosomes in your population
4. Perform natural selection and select the two fittest chromosomes
5. Use the parents from (4) and perform crossover to get 2 offspring
6. Perform mutation and check the fitness of the final offspring. Comment…
arrow_forward
The best sequence is list of actions, called
solution
problem
Path
search
The Optimal solution is : *
a path from the initial state to a state satisfying the goal test
This process of looking for the best sequence is called
the solution with lowest path cost among all solutions
none
arrow_forward
This is an algorithmic graph problem.
Consider a set of movies M1, M2, ... , Mk. There is a set of customers, each one of which indicates the two movies they would like to see this weekend. Movies are shown on Saturday evening and Sunday evening. Multiple movies may be screened at the same time.
You must decide which movies should be televised on Saturday and which on Sunday, so that every customer gets to see the two movies they desire. Is there a schedule where each movie is shown at most once? Design an efficient algorithm to find such a schedule if one exists.
arrow_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 and determine which option is correct.
O NP is the set of problems that cannot be solved in polynomial time.
NP is the set of problems whose answer can be found in polynomial time.
O NP is the set of problems whose answer cannot be found in polynomial time.
O NP is the set of problems that can be verified in polynomial time.
O NP is the set of problems that cannot be verified in polynomial time.
arrow_forward
The Optimal solution is : *
a path from the initial state to a state satisfying the goal test
This process of looking for the best sequence is called
the solution with lowest path cost among all solutions
none
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 completely
arrow_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_forward
Gradient Descent Algorithm
iii) Generate the graph of f(xk) vs k where k is the iteration number and xk is the current estimate of x at iteration k. This graph should convey the decreasing nature of function values.
Deliverable(s) : The graph that is generated.
arrow_forward
Question 14 of 20 :
Select the best answer for the question.
14. Use Gauss-Jordan elimination to solve the following linear system:
-3x + 4y = -6
5x - y = 10
O A. (2,0)
о в. (2, -5)
OC.(-6,2)
O D. (2,2)
O Mark for review (Will be highlighted on the review page)
>
esc
$
%
*
3
4 8
5 0
8 A
W 3
E
R
ض
U
A
S
F
D
arrow_forward
Question 14 of 20 :
Select the best answer for the question.
14. Use Gauss-Jordan elimination to solve the following linear system:
-3x + 4y = -6
5x - y = 10
O A. (2,0)
о в. (2, -5)
O C.(-6,2)
O D. (2,2)
O Mark for review (Will be highlighted on the review page)
>
esc
->
%
*
4 8
50
8 A
ض
R
U
A
S
F
D
#3
arrow_forward
Use the greedy algorithm below to solve the activity problem. Suppose the
s={a1,a2,...,an} is a set of n activities that wish to use the resource. Each activity a; has
a start time s; and a finish time fi, where Activities a; and a; are called compatible if the
one starts after the other is finished. It is about to select the maximum-size subset of
mutually compatible activities. Solve this problem of activity-selection problem. Is this
optimal solution? What is the optimal solution? How can you improve it?
i
S₁
fi
1
0
4
2
1
3
3
3
4
4
5
11
5
5
9
6
10
11
The greedy algorithm
1 n = s.length
2
min = f[1]
3
k = 1
4
5
6
7
for i = 2 to n
if f[i]
arrow_forward
True or False: and explain why. (CH12 NP-Completeness)
a.
It is known that PC NP.
b. If a decision problem is hard, the corresponding optimization problem is also
hard.
C.
The Traveling salesperson problem is known to be not in P.
d. Suppose the clique problem is polynomially reducible to the vertex-cover
problem. If the vertex-cover problem is in P, then the clique problem is also in P.
e.
If a problem is shown to be NP-Complete, it is likely that it is not in P.
f.
The worst-case running time of a non-deterministic computation looks at the
height of its computation tree.
g. All the NP-complete problems are known to be reducible to one another
arrow_forward
Constructing an Optimal Solution:algorithm LCSWithAdvice x1, ... , xi, y1, ... , yj, birdAdvice pre- & post-cond: Same as LCS except with advice.
arrow_forward
Suppose a salesperson is planning a sales trip that includes n cities. Each city is
connected to some of the other cities by a road. To minimize travel time, the
salesperson wants to determine the shortest route that starts at the salesperson’s
home city, visits each of the cities once, and ends up at the home city.
This problem of finding the shortest route is called the Travelling Salesperson Problem
(TSP) and is a well-known problem that can be solved using Dynamic Programming.
Research about the TSP problem and find an algorithm based on Dynamic
Programming for that. Explain the approach, the algorithm, and its time complexity.
Use an example to explain the way the algorithm operates
arrow_forward
B. If a Genetic Algorithm suffers from local solution problem, what do you suggest to achieve global optimal solution?
arrow_forward
2. [20 points][MID] The graph k-coloring problem is stated as follows: Given an
undirected graph G = (V, E) with N vertices and M edges and an integer k. Assign to
each vertex v in V a color e(r) such that 1 < e{u) < k and c(u) # c(v) for every edge
(u, v) in E. In other words you want to color each vertex with one of the k colors you
have and no two adjacent vertices can have the same color.
For example, the following graph can be 3-colored using the following color assignments:
a=1,b=2,c=1,d%32,e=3,f=2.g33
a---b---c---g
d
Formulate the graph k-coloring problem as an evolutionary optimization. You may
use a vector of integer representation, OR any representation that you think is more
appropriate. you should specify:
• A representation.
• itness function. Give 3 examples of individuals and their fitness values if you
are solving the above example.
A set of mutation and/or crossover and/or repair operators. Intelligent operators
that are suitable for this particular domain will earn…
arrow_forward
Question 14 of 20 :
Select the best answer for the question.
14. Use Gauss-Jordan elimination to solve the following linear system:
-3x + 4y = -6
5x - y = 10
O A. (2,0)
О В. (2, -5)
O C.(-6,2)
O D. (2,2)
O Mark for review (Will be highlighted on the review page)
>
esc
->
$
%
*
4 8
5 0
8 A
W 3
ض
R
U
S
F
D
#3
回2
A.
arrow_forward
Explain NP and NP Complete problem.NP problem: NP: the class of decision problems that can be solved by nondeterministic polynomial (NP)algorithmsNP Complete problem:A decision problem D is said to be NP-complete if 1. It belongs to class NP. 2. Every problem in NP is polynomial reducible to D
arrow_forward
Question 1
Consider the following greedy algorithm for knapsack packing.
(a) Sort items in non-increasing order of v/s
(b) Greedily add items until we hit an item a, that is too big (-1 SL > B)
(c) Pick the better of {a1, a2, ...,aL-1} and {a}.
Your task is the following.
(a) Show that the value of the solution found by the greedy algorithm is at
least half of the (unknown) optimal value as the number of items n tends
to infinity. (2-Approximation)
(b) There exists an instance (set of itens) such that the optimal value reached
by the greedy algorithm is half of the value reached by the optimal algo-
rithm as the size of knapsack goes to infinity. (tightness)
arrow_forward
True or False:
- Best-first search is optimal in the case where we have a perfect heuristic (i.e., h(?) = h∗(?), the true cost to the closest goal state).
- Suppose there is a unique optimal solution. Then, A* search with a perfect heuristic will never expand nodes that are not in the path of the optimal solution.- A* search with a heuristic which is admissible but not consistent is complete.
arrow_forward
A given Knapsack with maximal Weight capacity is 8Kg. There are some items can be chosen and
taken into Knapsack. Each item has own weight and profit shown as follows. Please find the
maximal profit of Knapsack after some items are selected and put into this Knapsack and its maximal
Weight capacity isn't exceeded.
item ID Weight
4Kg
5Kg
2Kg
1kg
6Kg
A
B
с
D
E
Profit
4500
5700
2250
1100
8700
The maximal profit of this Knapsack to taken some items and total weight is no exceeded the weight
capacity :
The last item is taken and put into this Knapsack is:
The second item is taken and put into this Knapsack is :
The first item is taken and put into this Knapsack is:
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
![Text book image](https://www.bartleby.com/isbn_cover_images/9780534380588/9780534380588_smallCoverImage.gif)
Operations Research : Applications and Algorithms
Computer Science
ISBN:9780534380588
Author:Wayne L. Winston
Publisher:Brooks Cole
Related Questions
- 8. 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_forwardQuestion 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.arrow_forwardDevelop 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.arrow_forward
- knapsack problem: given the first table: c beeing value and w beeing weight, W max weight. I got table 2 as a solution to: 2 Solve the Knapsack problem with dynamic programming. To do this, enter the numbers Opt[k,V ] for k = 1,...,5 and V = 1,...,9 in a table. Here Opt[k, V ] is the partial solution obtained for the first k items with maximum weight V. " Can somebody explain me the values of the table? How do they get calculated? Also how do i solve the followup-task: Using the values in the table, determine a solution OPTSOL(I)=(β1,β2,β3,β4), starting with β4. (Use backtracing to do this)arrow_forwardesc A Question 14 of 20: Select the best answer for the question. 14. Use Gauss-Jordan elimination to solve the following linear system: -3x + 4y = -6 5x - y = 10 O A. (2,0) O B. (2,-5) OC. (-6,2) OD. (2,2) O Mark for review (Will be highlighted on the review page) > 2 T W S #3 E D لم G $ 4 { R C 19 F % 50 F ف G Oll O O U *00 C 8 Aarrow_forward(b) One example of a greedy algorithm is the Dijkstra algorithm for finding the lowest cost path through a weighted graph. The diagram below shows two weighted graphs that a student wants to investigate using Dijkstra's algorithm. In each case the task it to find the lowest cost of reaching every node from v₁. Each graph has a single negative weight in it. ● V₁ ● 10 ● 12 V₂ V3 10 V4 V₁ 15 Graph (a) Graph (b) One of the graphs will yield a correct analysis of the lowest cost for all vertices, and the other will produce an incorrect analysis. Which of the two graphs will produce the incorrect analysis, and explain why the greedy nature of Dijkstra's algorithm is responsible for the incorrect analysis. Your answer should include the key concept of an invariant. V₂ (c) The priority queue is a widely used data structure. Priority queues may be implemented using binary heaps and simple linear arrays. For the basic priority queue operations of: 30 Building an initial queue Taking the highest…arrow_forward
- Maximum weight = 20The above problem is a 0/1 Knapsack problem. Here there are 7 different objects labelled from A to G. The objective of this problem is to carry the different objects in your bag in such a way such that the profit is maximized. But you have to make sure that your bag does not exceed the maximum weight i.e. the maximum weight that this bag can carry is less than or equal to 15. Remember you can carry an object exactly once. Now it is your job to use Genetic Algorithm to solve this problem. 1. Encode the problem and create an initial population of 4 different chromosomes 2. Think of an appropriate fitness function to this problem and give proper justification. 3. Use the fitness function to calculate the fitness level of all the chromosomes in your population 4. Perform natural selection and select the two fittest chromosomes 5. Use the parents from (4) and perform crossover to get 2 offspring 6. Perform mutation and check the fitness of the final offspring. Comment…arrow_forwardThe best sequence is list of actions, called solution problem Path search The Optimal solution is : * a path from the initial state to a state satisfying the goal test This process of looking for the best sequence is called the solution with lowest path cost among all solutions nonearrow_forwardThis is an algorithmic graph problem. Consider a set of movies M1, M2, ... , Mk. There is a set of customers, each one of which indicates the two movies they would like to see this weekend. Movies are shown on Saturday evening and Sunday evening. Multiple movies may be screened at the same time. You must decide which movies should be televised on Saturday and which on Sunday, so that every customer gets to see the two movies they desire. Is there a schedule where each movie is shown at most once? Design an efficient algorithm to find such a schedule if one exists.arrow_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 and determine which option is correct. O NP is the set of problems that cannot be solved in polynomial time. NP is the set of problems whose answer can be found in polynomial time. O NP is the set of problems whose answer cannot be found in polynomial time. O NP is the set of problems that can be verified in polynomial time. O NP is the set of problems that cannot be verified in polynomial time.arrow_forwardThe Optimal solution is : * a path from the initial state to a state satisfying the goal test This process of looking for the best sequence is called the solution with lowest path cost among all solutions nonearrow_forwardMachine 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_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
![Text book image](https://www.bartleby.com/isbn_cover_images/9780534380588/9780534380588_smallCoverImage.gif)
Operations Research : Applications and Algorithms
Computer Science
ISBN:9780534380588
Author:Wayne L. Winston
Publisher:Brooks Cole