title: Greedy Activity-Selector algorithm: n activities in smallest amout of lecture halls pseudo code
body: <p>I have spent hours trying to understand the answer to this problem. I just don't get it. Can somebody please give me some pseudo code (preferably pseudo code similar to Java) of the algorithm that would solve this problem based on the answer? That will help me understand what the answer is trying to say.</p>
  
  <p>Question and answer:</p>
  
  <p>Rather than typing it all out, it's styled better in this PDF. The question is the first one on the pdf, Exercise 16.1-4</p>
  
  <p><a href="http://mitpress.mit.edu/algorithms/solutions/chap16-solutions.pdf" rel="nofollow">http://mitpress.mit.edu/algorithms/solutions/chap16-solutions.pdf</a></p>
  
  <p>(To clarify, his is not homework, I am doing the bookwork and want to understand this problem. The link is the solution to the problem, but I don't understand it. I don't understand what it means when it says "To do this, move through a set of events consisting of activities starting and activities finishing, in order of event time..." and the rest of the explanation. This is why, if someone understands it, I would like if they could show me the pseudo code of what this is explaining. I could read and understand it that way. Like what the parameters of the function would be, and what is going on inside the function, how the activities are iterated through, how they move between the two lists of busy and free arrays of lecture halls, etc.)
  Thank you</p>