
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question

Transcribed Image Text:(S
10
3
Max Sum= 10 + 6 + 8 = 24
S
Max Sum=
2 + 3 + 5 = 10
Write an algorithm that, for a given tree T, calculates the maximum sum achievable across all
sets S (where no two elements have a parent/child relationship). You only need to return the
maximal sum and not a set of nodes that achieves it (for simplicity). What is the runtime and
space complexity of the algorithm?
Hint: For any given node n, come up with a recursive solution
MAX-SUM(n, include)
which calculates the maximum possible sum over a non parent/child subset S over a tree rooted
at node n. The parameter 'include' determines if node n should be included in a set S or not
(this impacts which of the descendants of n can be used).
Note that the maximum sum for the entire tree is given by MAX-SUM(T.root, true) +
MAX-SUM(T.root, false).
Then, use dynamic programming techniques to avoid solving the same call to MAX-SUM more
than once. Memoization can be done by adding two new fields to each node
(n.maxSumNodelncluded and n.maxSumNodeExcluded).
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 4 steps

Knowledge Booster
Similar questions
- Please answer all questions in detail and with pseudo codes.arrow_forwardUse a recursion tree to determine a good asymptotic upper bound on therecurrence T(n) = 3T(n/2) + n. Use the substitution method to prove your answer.arrow_forwardWhat is the time complexity of functions foo() and bar() respectively in below given code snippets, given that n is the total size of the input and L and R are Vectors def foo(L, R): S = Vector() for x in L: if x in R: S.add_back(x) return S def bar(L, R): R_hash= HashTable() for r in R: R_hash.insert(r, False) S = Vector() for x in L: if R_hash.contains(x): S.add_back(x) return S O(N^2), O(N) O(N), O(N) O(N^2), O(N^2) O(1), O(N)arrow_forward
- How do I do this using the recursion tree method? Thanksarrow_forwardApply quicksort to sort the list E, X, E, R, C, I, S, E in alphabetical order.Draw the tree of the recursive calls made.arrow_forwardSolve using the recursion tree T(n) = 4T(n-1) + c, where c is a positive constant, and T(0)=0.arrow_forward
- Redesign the topsort algorithm below so that it selects the last node in each iteration rather than the first. Please use python ad show all work so I can better understand the problem. def topsort(G): count = dict((u, 0) for u in G) for u in G: # The in-degree for each node for v in G[u]: count[v] += 1 Q = [u for u in G if count[u] == 0] S = [] while Q: u = Q. pop() S.append (u) for v in G[u]: count[v] -- 1 if count[v] # Count every in-edge # Valid initial nodes # The result # While we have start nodes... # Pick one # Use it as first of the rest # "Uncount" its out-edges # New valid start nodes? 0: == Q. append (v) # Deal with them next return Sarrow_forwardConsider the following variation on MergeSort: instead of dividing a list (say, of integers) evenly (that is, half and half or half and half plus 1) at all levels of recursion, we choose to divide a list this way - a left list that consists of exactly one integer and a right list that consists of the remaining integers. The time-complexity of this variation of MergeSort is: (a) O(n log n) (b) O(n²) (c) O(n) (d) none of the abovearrow_forwardUse the recursion tree method to solve the following recurrence T(n) by finding the tightest function f(n) such that T(n) = O(f(n)). T(n) ≤ 4.T(n/3) +0(n³)arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY

Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON

Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning

Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education

Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY