View the step-by-step solution to:

Problem 1 [25 points] A company is planning a party for its employees.

Problem 1 [25 points]
A company is planning a party for its employees. The organizers of the party want it to be a
fun party, so they have assigned a ’fun’ rating to every employee (for any employee x, x’s fun
rating is denoted by fun(x)) and are planning to invite employees that will maximize fun.
The employees at the company are organized into a strict hierarchy, which is encoded as a
tree T rooted at the president root(T) of the company. Each node is an immediate supervisor
of its children. However, there is a restriction: An employee and his immediate supervisor
(his parent in the tree) cannot both attend, because otherwise there would be no fun at all.
a) Give an algorithm that makes a guest list for the party that maximizes the sum of
’fun’ ratings of the guests. Denoting the total number of company employees by n,
your function should have O(n) time complexity. Show the pseudocode, argue that your
algorithms is correct, and argue that its complexity is indeed O(n). Again, make sure
that for any guest, the guest’s immediate supervisor does not attend (and at the same
time, that the overall fun rating of guests is maximized).
b) How would you modify your algorithm to always select the president of the company
(regardless of his fun rating or the consequences on the overall amount of fun we can
achieve)? How would the time complexity change? Show the modification of the pseu-
docode, argue that your modification solves this part correctly, and explain what the
new time complexity is.

Recently Asked Questions

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.


Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question