Question
There are n friends who went on a trip together. When they came back, some of the friends owed money to other friends. Devise an
There are n friends who went on a trip together. When they came back, some of the friends owed money to other friends. Devise an algorithm that gives a sequence of transactions that resolves all of the debts by exchanging the least amount of money. (Assume that the data is given to you as a directed graph with positive edge weights such that each friend is a vertex and there is an edge of weight w from A to B if friend A owes friend B w dollars.) Consider the following greedy strategy for this problem: Candidate Greedy Strategy: For each person, calculate their total credit, meaning the total of all incoming edges minus the total of all outgoing edges.
There are n friends who went on a trip together. When they came back, some of the friends owed money to other friends. Devise an algorithm that gives a sequence of transactions that resolves all me that the data is given to you as a there is an edge o nging the least amount of money irected graph with positive edge weights such that weight w from A to B if friend A owes friend B w dollars.) Consider the following greedy strategy for this problem: Candidate Greedy Strategy: For each person, calculate their total credit, meaning the total of all incoming edges minus the total of all outgoing edges. iend is a vertex cred(A)-w(u, A)- (A, u) (u,A)EE (A,u)EE Let L be the person with the lowest credit and let H be the person with the highest credit If cred(L)|Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started