Assume there are n courses offered by the university, where each course has one or no prerequisites. If course j is the prerequisite for course i, then we are only allowed to take course i after course j. And after taking each course i, we can get a reward r_i. Given the reward and prerequisite for each course, design an algorithm to find the maximum total reward we can get by taking m courses. The time complexity should be O(nm^2).
Q: 1 3 5 a 2. Q. For Mst with kruskal's algorithm, number of option(s) in third step is/ are (a) 2 (b)…
A: minimum spanning tree using kruskal :
Q: Find the path from S to G using A* algorithm. Is it optimal ?
A: Find the path from S to G using A* algorithm. Is it optimal ?Basically,A* algorithm is best…
Q: In the country of Florida, it is said that coins (currencies) of the following face values are…
A: In the country of Florida, it is said that coins (currencies) of the following face values are…
Q: Consider a currency system that has the following coins and their values: dollar (100 cents),…
A: Given a value V, if we want to make change for V cents, and we have infinite supply of each of C = {…
Q: We want to send n cargo by n truck. Each truck can move only one cargo and receives different costs…
A: We want to send n cargo by n truck. Each truck can move only one cargo and receives different costs…
Q: ind the minimum number of platforms in a train station to avoid delays in the arrival of a train. In…
A: Required: Find the minimum number of platforms in a train station to avoid delays in the arrival of…
Q: Given the locations of the gas stations in some arbitrary order, describe an algorithm that finds an…
A: Below I have used "k - problem center " Greedy algo:
Q: Find the shortest path using greedy search from S to one of the goals G1 or G2 S: Initial state,…
A: Given two Goal states and we need to find the shortest state that can be obtained from S to G1 and…
Q: Consider the following problem. The input consists of n skiers with heights p1, ··· , pn , and n…
A: Lets see the solution.
Q: A. One greedy strategy to solve the knapsack problem is to consider the items in order of decreasing…
A: Knapsack Problem: Given: A set S of n objects, and a knapsack or bag with each object i…
Q: Apply the Master Theorem. Given the following recurrence relations which represent the time…
A: T(n) = aT(n/b) + θ( nd logpn ), where a >= 1, b > 1, d >= 0 According to Masters Theorem,…
Q: There are 5 towns A, B, C, D, E. There are one way streets between them with distances shown below…
A: given : A B C D EA 0 2 9 5 6B 1 0 3 4 2C 6 9 0 1 5D 2 4 1 0 2E 8 3 5 1 0
Q: alculating the optimal cut of the text t of length n, where we have m cut points given in the field…
A: Write the formula for calculating the optimal cut of the text t of length n, where we have m cut…
Q: Consider the following problem, and determine which aspects listed below are ambiguous (i.e., you…
A: Consider the following problem, and determine which aspects listed below are ambiguous (i.e., you…
Q: Consider 7 items along their respective weights and values I = I1, I2, I3, I4, I5, I6, I7 W =…
A: The capacity of knapsack W=15. Find the optimal solution of the fractional knapsackproblem. What is…
Q: Two thieves have just stolen n objects with values 1 ≤ w1, . . . , wn ≤ M respectively. They want to…
A: Given, n and M, find the maximum possible value of ∑i∈S wi. Algorithm, starts with an empty set S,…
Q: Explain the job sequencing with deadline algorithm and also find the solution for the instance n = 7…
A: Q,. Explain the job sequencing with deadline algorithm and also find the solution for the…
Q: 1. Please analyze the time complexity T(n) where the symbol n denotes the size of the input. (1)…
A: Here we start with substituting the values of n , and further moving to the higher values , form the…
Q: Given an array of digits D[1, . . . , n], find the largest multiple of three that can be formed by…
A: When there are multiple questions, we must answer the first one.
Q: least possible coins and the greedy approach will force the algorithm to pick
A: The Counting Coins problem is to count to a desired value by choosing the least possible coins and…
Q: A school is creating class schedules for its students. The students submit their requested courses…
A: In the above problem where we need to find the optimal schedule for all the students, this is a type…
Q: ys Length[1 .. n] and Priority[1...n]. For each meeting request i from 1 to n, Length[i] and…
A: It is defined as an algorithm (pronounced AL-go-rith-um) is a procedure or formula for solving a…
Q: A celebrity has planned to give his/her live performance in Mumbai. He/she needs to travel from…
A: Iterаtive deeрening А* (IDА*) is а grарh trаversаl аnd раth seаrсh аlgоrithm thаt саn…
Q: Suppose you have coins of denominations 1,3 and 4. You use a greedy algorithm, in which you choose…
A: For 14: NoFor 6: NoFor 10: NoFor 100: Yes
Q: Complexity handouts). Show that First Fit has an approximation ratio of at most 2. In particular,…
A: The bin-packing problem (BPP) can also be described using the knapsack problem terminology as…
Q: The Counting Coins problem is to count to a desired value by choosing the least possible coins and…
A: When looking for an answer, a greedy algorithm always chooses the best immediate, or local,…
Q: Consider a sequential search algorithm. Given a value, the algorithm scans a linear array until the…
A: Linear Search: The simplest search algorithm is linear Search. It sequentially traverses the array…
Q: From a list of participants’ ids, find which id is missing from the list. The participant ids sorted…
A: Pseudocode: Let n be the total numbers in the array The numbers are in the array A[] Input: The…
Q: . Please analyze the time complexity T(n) where the symbol n denotes the size of he input. 1) Given…
A: The complexity is related to input-size, where each call produce a binary-tree of calls Where T(n)…
Q: Consider a set of n independent tasks. All tasks arrive at t = 0. Each task Ti is characterized by…
A: Each task is released at a given constant rate Given by the period T All instances of a task…
Q: Find the best solution for the 0-1 knapsack problem using backtracking algorithm. We have 5 items…
A: The above question is solved in step 2 and step 3 :-
Q: Given a sequence X[1, . . . , n], find a longest increasing subsequence. Precisely define the…
A: According to the information given:- We have to find a longest increasing sub sequence. from the…
Q: Given a 2-dimensional arrayA[1..m, 1..n], compute the number of ways (paths) of starting at the…
A: (1). The two-dimensional array A[1..m,1..n] computes the number of ways from the top-left corner to…
Q: A school is creating class schedules for its students. The students submit their requested courses…
A: A school is creating class schedules for its students. The students submit their requested courses…
Q: Choose the correct answer for the question below: A greedy algorithm for a given problem:
A: A greedy algorithm for a given problem. A greedy algorithm is a simple , intuitive algorithm that is…
Q: Q; Solve the following recurrence by Master Theorem if applicable. Also find the efficiency class to…
A: The ask is to solve the given recurrence by Master Theorem T(n) = 4T(n/6)+n, T(1)=1
Q: Given an array of intervals I[1, . . . , n] where I[i] = [si, fi], find the minimum number of…
A: Define subproblem: If the intersection of two intervals [a, b] and [c, d], where a=b and c=d, is not…
Q: A group of n people are lying on the beach. The beach is represented by the real line R and the…
A: Based on Algorithm
Q: Design a dynamic programming algorithm for the following problem. Find the maximum total sale price…
A: The method of optimizing the plain recursion is known as the dynamic programming.
Q: Consider A* with h(n) = 0, answer the following: %3D 1. What's the name of the resulting algorithm,…
A: 1. For all cost are equal BFS is preferable because it is very optimal solution obviously Also in…
Q: What will be the result of brute algorithm if there are five students {B1,B2,G1,B3,G2 }. There are…
A: Given: We are given a problem in which we have 4 students named as B1,B2,B3,G1, and G2 are there.…
Q: Let S = {1,2...n} be a set activities, where activity i € S has a start time si, a finish time fi…
A: Let p(j) be the maximum profit and i < j such that interval i does not overlap with j. Let DPA be…
Q: Which one is the true statement? -A hash table can be used to make an algorithm run faster even in…
A: We need to find the correct option regarding hash tables.
Q: 33. Use the Backtracking algorithm for the 0-1 Knapsack problem (Algorithm 5.7) to maximize the…
A: answer is below-
Q: Consider the Coin Changing problem: Given n coin denominations 0 d, and find the values dd Describe…
A: coin change(d, n, k) M[n+1] M[0] = 0 for j in 1 to n minimum = INF for i in 1 to k…
Q: Parking (car Cars[], car Park[0, int Area) { Car Cr, int CrNb; CrNb <-- 0; Park <-- { }; Cr <--…
A: Solution:-- 1)The question given is given a pseudo code for the purpose of the system of the…
Q: Assume there are n courses offered by the university, where each course has one or no prerequisites.…
A: A Directed Acyclic graph can be drawn based on the prerequisites, and then topological sort can be…
Q: From the figure above, the goal is to reach the node G from the start node S. Giving that, if you…
A: the solution is an given below :
Assume there are n courses offered by the university, where each course has one or no prerequisites.
If course j is the prerequisite for course i, then we are only allowed to take course i after course j. And after taking each course i, we can get a reward r_i. Given the reward and prerequisite for each course, design an
algorithm to find the maximum total reward we can get by taking m courses. The time complexity should
be O(nm^2).
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images
- Assume there are n courses offered by the university, where each course has one or no prerequisites.If course j is the prerequisite for course i, then we are only allowed to take course i after course j. And after taking each course i, we can get a reward r_i. Given the reward and prerequisite for each course, design analgorithm to find the maximum total reward we can get by taking m courses. The time complexity shouldbe O(nm^2). Please only answer if you have the algorithmConsider the following version of Knapsack. Given are two weight limits Wi and W2, where WW2. Given are also n items (wi, ci), (W2, C2)..... (Wn, Cn), where w, is the weight and c the cost of the i-th item. We want to find a subset of these items of the highest cost, where the subset weights at least W₁ and at most W2. Give an O(nW₂) algorithm for this problem. (Recall that the cost (respectively weight) of a subset is the sum of the costs (respectively weights) of the items in the subset.)Consider the following version of Knapsack. Given are two weight limits W1 and W2, whereW1 ≤ W2. Given are also n items (w1, c1),(w2, c2), . . . ,(wn, cn), where wiis the weight and cithe cost of the i-th item. We want to find a subset of these items of the highest cost, wherethe subset weights at least W1 and at most W2. Give an O(nW2) algorithm for this problem.(Recall that the cost (respectively weight) of a subset is the sum of the costs (respectivelyweights) of the items in the subset.)
- a. Given n items, where each item has a weight and a value, and a knapsack that can carry at most W You are expected to fill in the knapsack with a subset of items in order to maximize the total value without exceeding the weight limit. For instance, if n = 6 and items = {(A, 10, 40), (B, 50, 30), (C, 40, 80), (D, 20, 60), (E, 40, 10), (F, 10, 60)} where each entry is represented as (itemIdi, weighti, valuei). Use greedy algorithm to solve the fractional knapsack problem. b. Given an array of n numbers, write a java or python program to find the k largest numbers using a comparison-based algorithm. We are not interested in the relative order of the k numbers and assuming that (i) k is a small constant (e.g., k = 5) independent of n, and (ii) k is a constant fraction of n (e.g., k = n/4). Provide the Big-Oh characterization of your algorithm.In this problem we have n jobs j1, j2, ..., jn, each has an associated deadline d1, d2, ..., dn and profit p1, p2, ..., pn. Profit will only be awarded or earned if the job is completed before the deadline. We assume that each job takes 1 unit of time to complete. The objective is to earn maximum profit when only one job can be scheduled or processed at any given time.Provide the pseudocode of an algorithm to find the sequence of jobs to do with the maximum total profit. Also describe the main idea of your algorithm using plain language.[Hint: You can select the jobs in a greedy way. You can use the following example to help your analysis.] Job J1 J2 J3 J4 J5 Deadline 2 1 3 2 1 Profit 60 100 20 40 20 The best job sequence would be J2 →J1 →J3.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 reasonable 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? A. Unreasonable algorithms may sometimes also be undecidable B. Heuristics can be used to solve some problems for which no reasonable algorithm exists C. Two algorithms that solve the same problem must also have the same efficiency D. Approximate solutions are often identical to optimal solutions
- Consider the challenge of determining whether a witness questioned by a law enforcement agency is telling the truth. An innovative questioning system pegs two individuals against each other. A reliable witness can determine whether the other individual is telling the truth. However, an unreliable witness's testimony is questionable. Given all the possible outcomes from the given scenarios, we obtain the table below. This pairwise approach could then be applied to a larger pool of witnesses. Answer the following: 1) If at least half of the K witnesses are reliable, the number of pairwise tests needed is Θ(n). Show the recurrence relation that models the problem. Provide a solution using your favorite programming language, that solves the recurrence, using initial values entered by the user.Write the formula for calculating the optimal cut of the text t of length n, where we have m cut points given in the field R.TIP: In the case of the first question, R = [3, 7, 17].C) Record the algorithm for calculating the optimal cut and estimate the time and complexity.Not every greedy approach works. For activity selection problem, your book gives examples which shows that the following greedy strategies don't work: the earliest start time, the shortest-duration activity, and the activity with the fewest overlaps. Give concrete examples to show that the 0-1 knapsack problem doesn’t work for: (a) the heaviest item first, (b) the lightest item first, (c) the most expensive item first, and (d) the least expensive item first.
- Calculate the optimal path from g to a using A* algorithm (as heuristic function, use the provided table)Correct answer will be upvoted else downvoted. Let C={c1,c2,… ,cm} (c1<c2<… <cm) be the arrangement of individuals who hold cardboards of 'C'. Let P={p1,p2,… ,pk} (p1<p2<… <pk) be the arrangement of individuals who hold cardboards of 'P'. The photograph is acceptable if and provided that it fulfills the accompanying requirements: C∪P={1,2,… ,n} C∩P=∅. ci−ci−1≤ci+1−ci(1<i<m). pi−pi−1≥pi+1−pi(1<i<k). Given a cluster a1,… ,an, kindly track down the number of good photographs fulfilling the accompanying condition: ∑x∈Cax<∑y∈Pay. The appropriate response can be huge, so output it modulo 998244353. Two photographs are unique if and provided that there exists no less than one individual who holds a cardboard of 'C' in one photograph yet holds a cardboard of 'P' in the other. Input Each test contains numerous experiments. The main line contains the number of experiments t (1≤t≤200000). Depiction of the experiments follows. The…Consider the following version of Knapsack. Given are two weight limits W 1 and W 2 , whereW 1 ≤ W 2 . Given are also n items (w 1 , c 1 ), (w 2 , c 2 ), . . . , (w n , c n ), where w i is the weight and c ithe cost of the i-th item. We want to find a subset of these items of the highest cost, wherethe subset weights at least W 1 and at most W 2 . Give an O(nW 2 ) algorithm for this problem.(Recall that the cost (respectively weight) of a subset is the sum of the costs (respectivelyweights) of the items in the subset.)